简体   繁体   English

如何清除Firebase上的service-worker.js缓存

[英]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 客户端刷新页面时仍然会获得旧代码

screenshot 屏幕截图

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.

相关问题 如何从Spring Boot正确地提供service-worker.js? - How to serve service-worker.js from spring boot properly? 如何在service-worker.js中更新动态网址 - How to Update dynamic url in service-worker.js 如何使service-worker.js在浏览器上执行? - How to make a service-worker.js to excecute on browser open? 如何清除服务工作者的缓存? - How to clear cache of service worker? fetch() 在 service-worker.js 中不起作用 - fetch() is not working in service-worker.js 跟踪对service-worker.js的未知调用 - Rails unknown calls to service-worker.js Rails PWA 中的 CacheStorage 始终为空。 在 service-worker.js cache.addAll 似乎没有缓存任何东西 - CacheStorage in Rails PWA always empty. In service-worker.js cache.addAll doesn't seem to cache anything Chrome甚至使用Cache-Control来缓存service-worker.js:不存储,不缓存最大年龄:0 - Chrome is caching service-worker.js even with Cache-Control: no-store, no-cache Max-Age: 0 如何以编程方式清除服务工作者缓存? - How to clear service worker cache programmatically? 是否可以将 service-worker.js 添加到现有的 React 应用程序中,如果可以,如何添加? - Is it possible to add service-worker.js to existing react app, if yes, how?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM