I set a far-reaching future for my CSS / Javascript headers so that browsers no longer request files after they are cached. I also have a simple version control mechanism, so if the files are changed, clients will know.
Basically, I have a template tag, and I'm doing something like
<script type="text/javascript" src="{{ MEDIA_URL }}{% versioned "javascript/c/c.js" %}"></script>
which will become
<script type="text/javascript" src="http://x.com/media/javascript/c/c.min.js?123456"></script>.
The template tag opens a file javascript/c/c.js.vwhere it finds the version number and adds it to the query string. The version is generated by the shell script (it is now launched manually, a pre-commit hook may be added), which checks if the file has changed (with git diff).
Everything works fine, EXCEPT:
I want to implement the same type of versions for images. But images can reference CSS - this is a static file (served by nginx) - so there is no template tag there.
Which is better for file versioning?
Alternatively, I am thinking of replacing the template tag with middleware that changes all the links before returning the response. This is better than a template tag that can be mistakenly excluded. But still does not solve the problem of images referenced by CSS.
In addition, I know that having a version as part of a query string can cause problems with some proxies that do not cache the file, so I believe that part of the version is part of the file - for example javascript/c/c.123456.js.
. , Django (, CSS Django). , , nginx.