Opened 5 years ago

Closed 5 years ago

Last modified 2 years ago

#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


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 Changed 5 years ago by Simon Charette

Resolution: wontfix
Status: newclosed

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 enabling DEBUG on it is not a good idea.

HashedFilesMixin based staticfiles storage return non-hashed urls when DEBUG=True to avoid forcing developers to run collectstatic every single time they change one of their static assets. The development server uses If-Modified-Since based cache busting for static assets so unless you are using a reverse proxy to serve STATIC_URL in your staging environment with aggressive caching enabled you shouldn't be affected by that.

comment:2 Changed 2 years ago by Carsten Fuchs

Just a note: I use a local Apache instance for development and thus run touch .../ 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

if not DEBUG:

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.

Note: See TracTickets for help on using tickets.
Back to Top