From the BlogSubscribe Now

How to Force Javascript File Updates onto Users

Wonka wonka wonka cache busting memeThe question came up when working with a new application that relies heavily on Javascript, How can we force users to renew the javascript file? This is especially important for single page applications that rely heavily on Javascript for everything from authentication to storing data.

In researching this problem, I found there to be a great deal many options at hand. Some suggested using a paramater in the overall application which could be used to version the javascript.

This would work, but it also requires a paramater in the URL, which I didn’t like for our needs.

Instead we opted to use a very similar method but in the file include statement, where it would be updated for future versioning. So where we call the javascript in the template files, we added a parameter to that javascript file, like so…

<script src="/js/custom.js?v=19228" type="text/javascript">

Let me know in the comments how you handle this problem and if there are any issues you find with our way of solving it.