Cache busting static assets: hashed filenames or query strings?
Most bundlers I've used put a content hash in the filename, like app.3f9a1c.js. On an older project we just append ?v=123 to the URL and bump it on deploy.
The query string approach is simpler but I've read some caches and proxies treat query strings inconsistently. Is there any reason to keep it around in a new project, or is filename hashing the clear winner?
Comments · 3
Hashed filenames, no contest. Query strings are sometimes ignored by CDNs or proxies, while a new filename is a new file everywhere.
Hashed names also let you cache assets for a year since a change produces a new URL. Big win for performance.
Don't forget to keep the HTML itself uncached or short-cached, since that's what points to the new hashed files.