Service Worker - 浏览器支持

Service Worker - Browser support

CanIUse and MDN doesn;t seems to be agree on the support for service worker. In the midst of Chrome going to remove 支持 appcach,我们正在尝试确定迁移到 Service Worker 的影响。我们是否错误地阅读了以上两页?

我们尝试了 Google 自己的 samples 对抗 device/browser 组合,结果并不令人鼓舞。例如,'custom offline page' 演示在 iOS Chrome (v80) 中失败,但它在 iOS Safari (12.4.5) 中有效。

'Selective caching' 和 'Read through caching' 页面清楚地显示 "service worker is not supported in the current browser" in Chrome 80。它正在检查 if ('serviceWorker' in navigator) {,但其他示例不显示此类消息。

浏览器对 Service worker 的支持令人困惑。是否有一个经过普遍测试的样本,我们可以将其用作不同 device/browser 组合的基准。

在 iOS 只有 Safari 支持服务工作者。您可以测试浏览器是否支持此代码

if ('serviceWorker' in navigator) { /*supported*/  }

我就此询问了 Google 的 Jake Archibald,他回答了以下 SO post,它必须仍然有效。

因此,显然 Safari 是目前唯一的选择。我仍然想知道 Google 是在建议开发人员在删除对 AppCache 的支持后使用什么。

Jake 继续说他们无法添加支持,因为 Apple 没有给他们 iOS 的全部权利。但他提到 appcache 将继续照常工作。他的原话是

"However, since Chrome on iOS is just a skin over Safari, appcache will continue to work while it works in Safari webview."