]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
settings: Help caching with content-aware static file names
authorDamien Lespiau <damien.lespiau@intel.com>
Thu, 4 Feb 2016 13:56:51 +0000 (13:56 +0000)
committerStephen Finucane <stephen.finucane@intel.com>
Fri, 1 Apr 2016 12:19:32 +0000 (13:19 +0100)
If we always serve the "style.css" file, even when its content changes,
we run into the situation where the browser (or any HTTP aware middle
man) will cache the file and not download a newer version.

This can be solved by appending the file hash to its filename. If the
content changes, the file name changes and the new version is used right
away. We can also use far future Expires headers with such static files,
they will really never change.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
---
v2: Disable for Django < 1.7

patchwork/settings/production.example.py

index 195ffcc837130c8d2199f8c18321a9e9aee1317b..89e6b97b319cdf5a3b339351b7ab461b9c0f4ec0 100644 (file)
@@ -11,6 +11,8 @@ from __future__ import absolute_import
 
 import os
 
+import django
+
 from .base import *  # noqa
 
 #
@@ -67,6 +69,10 @@ DATABASES = {
 #
 # Static files settings
 # https://docs.djangoproject.com/en/1.7/ref/settings/#static-files
+# https://docs.djangoproject.com/en/1.8/ref/contrib/staticfiles/#manifeststaticfilesstorage
 #
 
 STATIC_ROOT = os.environ.get('STATIC_ROOT', '/srv/patchwork/htdocs/static')
+
+if django.VERSION >= (1, 7):
+    STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'