6
votes
Why is there guid-like parameter when requesting js or css?
Hi, I looked through JS files and I noticed that all JS and CSS are called with weird parameter. tildes.css?aadf6c54
tildes.js?e6d30b42
third_party.js?4393e99
(I changed the string after ?
)
Does anyone know why is it done and what does it mean?
That's usually referred to as a "cache buster": https://www.keycdn.com/support/what-is-cache-busting
It lets me tell browsers that they can download the static files once and never need to re-download them. When I change one of those files, the cache buster string also changes, and the browser will recognize that the filename changed and download the new version (once).
Fun tip (for you or anyone else), if you make the filename content-addressable in some way (eg.
static/css/main-$sha256OfContent.css
),Cache-Control: immutable
(documentation) makes a lot of sense to use and is a lot more aggressive than usual cache control methods such as bare max-age (will prevent even the initial request).Looks like that has horrible browser support though. Chrome and its mountain of children don't support it on Desktop, and nobody but Safari supports it on Mobile.
Yep, it's very recent. I just checked the compatibility table and it's worse than I imagined, but other browsers will just ignore it if they don't support it afaik.
I'm looking forward to better support for it though, it's one of those things that makes a ton of sense which we don't have on the web, despite having a mountain of other obscure features.
We really need a save feature so we can save comments like this. This is something I'm going to refer back to quite a bit this is cool.
Work in progress:
https://gitlab.com/tildes/tildes/merge_requests/27