Reputation: 539
I am trying to execute last modified JavaScript after i change it, however, browsers insist on using cached data. I use shift+f5 to override cached data and download fresh copy from the server. It works for this case.
Lets assume that i launched the site and its used constantly.
After i change a JavaScript file. None of the user will not be able to see the changes (for who entered the site before the change). So, how can i force all clients to erase or ignore current cached data and download all the site.
I found a workaround. If i change the file name, browser downloads it. Which is not surprising. Is there any other solution (preferably more professional) to make browser ignore cached data?
Upvotes: 0
Views: 877
Reputation: 588
Let say your file is <script src = "javascript-code.js"></script>
, if you edit it and would like the have it automatically reload on all the other client browsers you can rename it <script src = "javascript-code.js?rnd=123"></script>
. Changing the value in the query string will force the browsers which cached the JS to get a fresh copy from the server.
Upvotes: 1