How to Invalidate Web Browser Cache Content

Keefer picture Keefer · Feb 3, 2012 · Viewed 12.7k times · Source

I've been really digging into Google Page Speed, optimizing a lot of the sites I'm working on to score well on that -- and quite successfully I'm proud to say.

The only downside I've come across is that by some of the caching stuff being done, small changes to JS and CSS tend not to cause a new copy of the files to download.

Is there any way when changes are made to the JS, CSS (or other resources) to force a new copy to download?

Answer

Rob picture Rob · Feb 3, 2012

I'm running into similar issues sometimes that JS and CSS is cached to long. The solution that works for me is, adding an versionnumber or timestamp of the last update to the filename as querystring. This way the browser sees the file as changed and it will download it again.

Could be something like this for getting JS:

http://yourdomain.com/content/js/functions.js?v=201232