Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23798 closed New feature (wontfix)

Improve "static" template tag to generate staticfiles revision

Reported by: Alexey Zankevich Owned by: nobody
Component: contrib.staticfiles Version: dev
Severity: Normal Keywords: templatetags staticfiles
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently "static" template tag generates a link without revision, however it would be a good mechanism to force udpate static files on client side.

Current implementation:
{% static "path/to/file.js" %} -> /static/path/to/file.js

Proposal:
{% static "path/to/file.js" %} -> /static/path/to/file.js?<revision>

where <revision> defined as STATIC_REVISION variable in settings. If STATIC_REVISION is not defined, "static" tag will failback to the current behavoir.

I can make a fix if it's considered as a good idea.

Change History (3)

comment:1 by Alexey Zankevich, 10 years ago

Version: 1.7master

comment:2 by Carl Meyer, 10 years ago

Resolution: wontfix
Status: newclosed

Hi! Thanks for the suggestion.

There are several third-party solutions already that will append a revision to your files (as well as concatenating/minifying them), without even the need to maintain a manual STATIC_REVISION setting. See for instance django-pipeline.

I am not sure that the solution you propose (with the addition of a new setting) is clearly enough the best option that it should be integrated with Django. It should be easy to implement as a third-party template tag extending the built-in static tag.

comment:3 by Preston Timmons, 10 years ago

The built-in ManifestStaticFilesStorage is also available. It adds a revision to the filename based on the file contents and works without an additional setting.

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