So far, here are some of the old Cache Buster techniques I've come across:
- Adding a query string in the link src: /mstylesheet.css?cache_buster=12345
- Changing the filename each time: /mstylesheet-12345.css
- Using Apache with Cache-Control "must-revalidate" along with no-cache
I've encountered issues with all of these methods as browsers stubbornly refuse to update assets.
Based on my understanding, it seems like browser caches view the following URLs as distinct entities:
- /mstylesheet.css
- /mstylesheet.css?cache_buster=12345
- /mstylesheet.css?cache_buster=54321
Therefore, the question arises: Will the following javascript code be effective in forcing an existing stylesheet, linked via a link tag without a cache buster query string, to be updated in the browser cache?
fetch("/mstylesheet.css",{ method: "GET",headers: {"Cache-Control": "no-cache"}});
(I would like this to run occasionally, not every time a page loads).