[英]How to clear service-worker.js cache on firebase
How do I force client machine to clear the service worker cache after I deploy to firebase? 部署到Firebase后,如何强制客户端计算机清除服务工作者缓存? Clients still getting old code when they refresh the page
客户端刷新页面时仍然会获得旧代码
I believe your problem is that the service worker has cached your page's index.html and the client is being served with that from the cache when there's actually a fresh one available in the background. 我相信您的问题是服务工作者已经缓存了您页面的index.html,而后台实际上有一个可用的缓存时,正在从缓存中为客户端提供服务。 The client always gets the old index.html which points to the old JS, CSS etc.
客户端总是获得旧的index.html,它指向旧的JS,CSS等。
You have basically two options: 您基本上有两个选择:
If your service-worker.js lists all files that should be cached , just simply update your service-worker.js and the cache name . 如果您的service-worker.js 列出了所有应缓存的文件,只需更新service-worker.js和缓存名称 。 The browsers automatically update the SW when they see the change.
浏览器在看到更改后会自动更新软件。 They automatically check to see if there's even a single-byte change.
他们会自动检查是否有单字节更改。
If your SW dynamically caches files and returns them from the cache the next time they are requested, you should programmatically check for updates every time you serve something from the cache. 如果您的软件动态地缓存文件并在下次请求它们时从缓存中返回它们,则每次您从缓存中提供内容时,都应该以编程方式检查更新。 You can find code examples here: https://serviceworke.rs/strategy-cache-and-update_service-worker_doc.html
您可以在此处找到代码示例: https : //serviceworke.rs/strategy-cache-and-update_service-worker_doc.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.