#28847 closed New feature (wontfix)
Manifest/CachedStaticFilesStorage should keep providing cache-busting when DEBUG is true
Reported by: | Dan Raviv | Owned by: | nobody |
---|---|---|---|
Component: | Core (Cache system) | Version: | dev |
Severity: | Normal | Keywords: | cache, storage, DEBUG |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
What is the rationale for these storages not behaving the same when DEBUG is on? I tend to have DEBUG on on my staging server, and the fact that cache busting stops working in that case is very visible, e.g., outdated css is being used.
As a general guideline, DEBUG-enabled behavior should be as similar as possible to regular release behavior, so as to help analyze release-like behavior with all of the help that enabling DEBUG gives you.
Change History (2)
comment:1 by , 7 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:2 by , 5 years ago
Just a note: I use a local Apache instance for development and thus run touch .../wsgi.py
after every change and collectstatic
after any change to static files anyways. I too was surprised that the hashed versions of paths are not used in DEBUG
mode. The problem can be solved by overriding the url()
method of ManifestStaticFilesStorage
, but I'd rather explicitly write in settings.py
:
if not DEBUG: STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
to achieve more convenient development with runserver
than having this decision anticipated in ManifestStaticFilesStorage
.
In other words, I concur with the original poster: ManifestStaticFilesStorage
should work the same with DEBUG = True
. A developer that consciously enables ManifestStaticFilesStorage
but doesn't want to have it in development can express this explicitly as shown above.
There are many components of Django that will behave differently when
DEBUG=True
as it's only meant to be used during development. Given a staging server's role is to mimic production as closely as possible I would argue that enablingDEBUG
on it is not a good idea.HashedFilesMixin
based staticfiles storage return non-hashed urls whenDEBUG=True
to avoid forcing developers to runcollectstatic
every single time they change one of their static assets. The development server usesIf-Modified-Since
based cache busting for static assets so unless you are using a reverse proxy to serveSTATIC_URL
in your staging environment with aggressive caching enabled you shouldn't be affected by that.