So I update my static files (HTML, CSS, JS) somewhat frequently. The biggest problem with this is that the visitor’s browsers will still have the older versions cached, and I don’t want to have them clear it out so often (or at all ideally for something like this).
How would I go about doing this?
P.S. Enabling “ManifestStaticFilesStorage” broke my admin page and caused a 500 Internal server error. I suspect I am missing something.
This is what I’d suggest using so it is worth figuring out why it is causing other issues for you.
Beyond that, you can control how long clients cache resources by having the web server set appropriate headers, e.g. Cache-Control on those static files.
This is what I saw as well. I suppose I could just post date and timestamps into the filename, but that could get messy kinda quickly. I was sorts hoping for something automatic, which was what I discovered “ManifestStaticFilesStorage” is for.
Okay… well, I attempted the setting again and may have fixed the problem. Permissions were not the issue. I think I forgot some steps the first time I did it. This time, I mentally recorded the steps while testing again:
Enable the storage setting
Refresh admin page as change is applied to server (resulted in error)
run collectstatic
Refresh (2 types: Normally, and override cache) - sometimes works, sometimes doesn’t.
Restart gunicorn daemon (Python HTTP Server)
Refresh and test admin pages.
Things work as they should now. Pretty sure I forgot to do one or more of these things initially.
I’ll admit I’m only recently finding this setting, and getting back to Django after a a few months due to time constraints…
Thanks for the help.