Web Worker: How to prevent that file gets loaded from cache?

旧时模样 提交于 2019-12-13 15:31:26

问题


This is incredibly annoying.. I am wondering why the heck my changes aren't reflected as I notice that my JavaScript file for my Web Worker always gets loaded from cache:

I have disabled the Cache and hitting Ctrl + F5 does not work either.

How can I make sure that this file does not get loaded from cache?

_worker = new Worker('js/toy-cpu.js');

回答1:


You could add a kind of version number, for example like this:

_worker = new Worker('js/toy-cpu.js?v=' + new Date().getTime());



回答2:


If you are looking for the purposes of development / the configuration of your personal machine.. rather than that every user needs it to load from the web server.

Chrome has an option to disable cache

Notice the checkbox "disable cache" that you can check as I have.

And in the section below, where it says "Perform a request". if you refresh then you see the page listed, and it can indicate whether a URL is loaded from the web server, if chrome says 200 and if in the size column it gives size as a number, then it loaded from the web server. And if you double click a URL in the inspector, you see HTTP Headers.



来源:https://stackoverflow.com/questions/33356430/web-worker-how-to-prevent-that-file-gets-loaded-from-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!