How to force IE to reload javascript?

Add a string at the end of your URL to break the cache. I usually do (with PHP):

<script src="https://stackoverflow.com/my/js/file.js?<?=time()?>"></script>

So that it reloads every time while I’m working on it, and then take it off when it goes into production. In reality I abstract this out a little more but the idea remains the same.

If you check out the source of this website, they append the revision number at the end of the URL in a similar fashion to force the changes upon us whenever they update the javascript files.

Leave a Comment