简体   繁体   中英

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

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');

您可以添加一种版本号,例如:

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM