- 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`
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:
{{{
#!python
STATICFILES_MANIFEST_EXCLUDES = (
"*.pdf",
"static/3rdparty/",
)
}}}
Does that make sense?
--
Ticket URL: <https://code.djangoproject.com/ticket/31447>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => wontfix
Comment:
A new setting is not necessary, you can use
[https://docs.djangoproject.com/en/3.0/ref/contrib/staticfiles/#cmdoption-
collectstatic-ignore the collectstatic --ignore option], see #28566.
--
Ticket URL: <https://code.djangoproject.com/ticket/31447#comment:1>
Comment (by Carsten Fuchs):
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/31447#comment:2>
Comment (by felixxm):
Replying to [comment:2 Carsten Fuchs]:
> 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.
You should be able to [https://docs.djangoproject.com/en/3.0/howto/custom-
file-storage/#writing-a-custom-storage-system write a custom] subclass of
[https://docs.djangoproject.com/en/3.0/ref/contrib/staticfiles/#manifeststaticfilesstorage
ManifestStaticFilesStorage] for this. We don't want to provide settings
for customizing the `ManifestStaticFilesStorage` behavior.
--
Ticket URL: <https://code.djangoproject.com/ticket/31447#comment:3>
Comment (by Carsten Fuchs):
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!
--
Ticket URL: <https://code.djangoproject.com/ticket/31447#comment:4>