服务人员到期 [英] Service Worker expiration

查看:89
本文介绍了服务人员到期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一旦安装了Service Worker,Chrome浏览器要花多长时间检查它的较新版本?当前的客户端服务工作者通常何时过期?

我正在尝试找出与Service Workers进行开发并将变更推向产品的最佳实践.当前,一旦对Service Worker的行为进行了更改,如果已经安装了以前的Service Worker,客户端就不会总是接管此事.

这个问题也有些相关:以编程方式更新服务人员-理想的情况是一旦更改实施为SW,您可能想在所有可能具有旧版本的客户端上强制对其进行更新.

解决方案

默认情况下,服务工作人员会在 24小时后过期.但是最好的方法是使用 max-age = 0 标头.因为我们希望我们的更改能尽快反映出来.我不知道强制更新,但是当它们没有缓存Service Worker文件并且没有为以前的Service Worker打开选项卡时,新的Service Worker将自动安装.

请参阅此链接以获取更多信息 https://jakearchibald.com/2016/caching-best-practices/

Once the Service Worker is installed, how long does it take for Chrome browser to check for a newer version of it? When does current client-side service worker expire usually?

I'm trying to figure out best practice for developing with Service Workers and pushing changes to prod. Currently, once there is a change implemented on how Service Worker behaves, clients are not always picking that up if a previous Service Worker has already been installed.

This question is also somewhat relevant: Programmatically update service worker - ideally once a change is implemented to SW you'd want to force update it on all clients that might already have previous version of it.

解决方案

By default service workers expires after 24 hours. But the best approach is to use max-age = 0 header. Because we want our changes to reflect as soon as possible.I don't know about force updating but when their is no caching of service worker file and no tab is open for previous service worker then the new service worker will install automatically.

refer to this link for more info https://jakearchibald.com/2016/caching-best-practices/

这篇关于服务人员到期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆