Rebooting / Preventing Web Workers Caching

I noticed that most browsers (Chrome in particular) seem to cache web worker scripts even after forcibly reloading the page (SHIFT + F5, etc.). The only reliable way I'm trying to update the cache is to enter the script working path into the address bar and force it to reload separately.

Obviously, this is a terrible pain when trying to develop, well, anything. Does anyone know of a reliable way to either stop the browser from caching working scripts, or make it restart them in a simple way?

+4
source share
3 answers

Have you tried using the Cache-Control: no-cache HTTP header to avoid caching a working script? You can usually get the caching behavior that you want to set the appropriate HTTP headers .

+2
source

If you do not have access to the server configuration files or your meta tags are not executed, a quick workaround would be to include a "web worker script" to load using the html header.

  <html> <head> <meta http-equiv="Cache-control" content="no-cache"> <script src="jquery_or_other_lib.js"></script> <script src="normal_site_scripts.js"></script> <script src="webworker.js"></script> </head> <body> </body </html> 
+5
source

Old question and old solution that I used today. When developing, create a web artist with a random number query string added to the work file:

var worker = new Worker ('path / to / worker / file.js' + '?' + (Math.random () * 1000000));

Remember to remove the query string before the code starts working!

+2
source

All Articles