You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The docs for WHITENOISE_KEEP_ONLY_HASHED_FILES indicate that it can be used to keep only hashed versions of files, which is useful for reducing the size of static files that need to be included in e.g: a Docker image or uploaded to a CDN. This sounds like it's potentially very useful, both for storage costs and build times.
However it's not clear how to use this together with WHITENOISE_ROOT, where you typically do want the non-hashed filenames (though only for a very small number of files).
Is there something in Whitenoise which can translate from the non-hashed names to the hashed names, so that at runtime both are served? Or are these two options incompatible?
Is there a way to use these together for most files, but then to keep the plain filenames around for those in WHITENOISE_ROOT? (Given the small number and likely small size of the latter, maintaining the duplication here feels reasonable).
The text was updated successfully, but these errors were encountered:
The WHITENOISE_KEEP_ONLY_HASHED_FILES setting only applies to files which pass through Django's staticfiles pipeline i.e. discovered by the various STATICFILES_FINDERS and collected into STATIC_ROOT. Django takes care of mapping from the original names to the hashed names using the static template tag.
Files in WHITENOISE_ROOT exist outside of Django's staticfiles pipeline and so are unaffected by this setting.
Files in WHITENOISE_ROOT exist outside of Django's staticfiles pipeline and so are unaffected by this setting.
Ah, I see. I'd not realised that that was the expectation, though that explains how these could work together.
Our setup has a directory within the staticfiles which contains the files we want in the root and which is thus referenced by WHITENOISE_ROOT.
I'm not actually sure why our setup is like that, though I know it pre-dates our use of Whitenoise. I'm guessing it does mean we have a single pipeline for all frontend/static files, which is potentially useful in keeping it simple.
Description
The docs for
WHITENOISE_KEEP_ONLY_HASHED_FILES
indicate that it can be used to keep only hashed versions of files, which is useful for reducing the size of static files that need to be included in e.g: a Docker image or uploaded to a CDN. This sounds like it's potentially very useful, both for storage costs and build times.However it's not clear how to use this together with
WHITENOISE_ROOT
, where you typically do want the non-hashed filenames (though only for a very small number of files).Is there something in Whitenoise which can translate from the non-hashed names to the hashed names, so that at runtime both are served? Or are these two options incompatible?
Is there a way to use these together for most files, but then to keep the plain filenames around for those in
WHITENOISE_ROOT
? (Given the small number and likely small size of the latter, maintaining the duplication here feels reasonable).The text was updated successfully, but these errors were encountered: