Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
54
rated 0 times [  56] [ 2]  / answers: 1 / hits: 8349  / 4 Years ago, sun, october 11, 2020, 12:00:00

Is there any workaround to auto clear the cache as we update the javascript code? It always happen where when I do the script code changes, from other user device, they won't be able to see the new update of the website because their browser is still reading the old script and they will see this as a bug since they do not know about this cache stuff. I have to mention the cache every time when there is an update made which is giving a bad experience to the user.


Usually for an image, I will set some additional unique id from the get method inside the url so that the website is able to read the latest update. But for javascript / jquery, I wonder if there is any kind of code to force the browser to read the new update instead of manually clearing the cache.


More From » jquery

 Answers
4

You have 3 options:



  1. Put this in the head section of your html page :


<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />

This will make your app to not cache anything at all ( at least you can keep it during
development)



  1. Use hard refresh for example ctrl+f5 if you are using chrome every time you reload.



  2. Use a Cache killer plugin for your browser. There's a bunch of them out there, you just install them and enable them whenever you want.




[#2515] Wednesday, October 7, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
sonja

Total Points: 541
Total Questions: 113
Total Answers: 114

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
sonja questions
Mon, Nov 30, 20, 00:00, 4 Years ago
Thu, May 21, 20, 00:00, 4 Years ago
Sun, Nov 10, 19, 00:00, 5 Years ago
Mon, Aug 26, 19, 00:00, 5 Years ago
;