#31447 closed New feature (wontfix)
ManifestStaticFilesStorage should have file exclude patterns.
Reported by: | Carsten Fuchs | Owned by: | nobody |
---|---|---|---|
Component: | contrib.staticfiles | Version: | 3.0 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
ManifestStaticFilesStorage
covers all files found by the static files finders.
However, it is not always desirable to have all files covered:
- files for user download, e.g.
usermanual.pdf
:- such files are not cached by browsers and thus require no cache busting
- files with hashes in their file name impair the user experience
- files where the cache busting is done by other means:
- e.g. when an explicit version string is already kept in other ways, e.g. manually as in
jquery-3.4.1.slim.min.js
- e.g. when an explicit version string is already kept in other ways, e.g. manually as in
Thus it would be helpful if files could be excluded from the manifest processing. For example, a setting with glob patterns could be introduced such as:
STATICFILES_MANIFEST_EXCLUDES = ( "*.pdf", "static/3rdparty/", )
Does that make sense?
Change History (4)
comment:1 by , 5 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Summary: | ManifestStaticFilesStorage should have file exclude patterns → ManifestStaticFilesStorage should have file exclude patterns. |
follow-up: 3 comment:2 by , 5 years ago
Hello Felix,
sorry, my description was probably not clear:
When we use ManifestStaticFilesStorage
, the collectstatic
command copies and creates static files such that the result is, for example:
usermanual.4b127df11c35.pdf usermanual.pdf
In a template, using {% static 'usermanual.pdf' %}
, links to .../static/usermanual.4b127df11c35.pdf
are generated. What I intended with the above suggested STATICFILES_MANIFEST_EXCLUDES
setting is to have only
usermanual.pdf
copied and {% static 'usermanual.pdf' %}
generating a link to .../static/usermanual.pdf
, just as if not the manifest, but the default StaticFilesStorage
was used. (For all files not covered by STATICFILES_MANIFEST_EXCLUDES
, the hashed paths should be used.)
In contrast to that, collectstatic --ignore
doesn't copy the ignored files at all, causing {% static 'usermanual.pdf' %}
to raise an exception.
comment:3 by , 5 years ago
Replying to Carsten Fuchs:
Hello Felix,
sorry, my description was probably not clear:
When we useManifestStaticFilesStorage
, thecollectstatic
command copies and creates static files such that the result is, for example:
usermanual.4b127df11c35.pdf usermanual.pdfIn a template, using
{% static 'usermanual.pdf' %}
, links to.../static/usermanual.4b127df11c35.pdf
are generated. What I intended with the above suggestedSTATICFILES_MANIFEST_EXCLUDES
setting is to have only
usermanual.pdfcopied and
{% static 'usermanual.pdf' %}
generating a link to.../static/usermanual.pdf
, just as if not the manifest, but the defaultStaticFilesStorage
was used. (For all files not covered bySTATICFILES_MANIFEST_EXCLUDES
, the hashed paths should be used.)
In contrast to that,
collectstatic --ignore
doesn't copy the ignored files at all, causing{% static 'usermanual.pdf' %}
to raise an exception.
You should be able to write a custom subclass of ManifestStaticFilesStorage for this. We don't want to provide settings for customizing the ManifestStaticFilesStorage
behavior.
comment:4 by , 5 years ago
Okay! I thought this might be of general interest, but reconsidering I think you're right, this is better placed in a subclass. Thank you!
A new setting is not necessary, you can use the collectstatic --ignore option, see #28566.