Better way to prevent browser caching of JavaScript files

You want CSS and JS to be cached. It speeds up the loading of the web page when they come back. Adding a timestamp, your user’s will be forced to download it time and time again.

If you want to make sure they always have a new version, than have your build system add a build number to the end of the file instead of a timestamp.

If you have issues with it just in dev, make sure to set up your browsers to not cache files or set headers on your dev pages to not cache.

Leave a Comment