不支持它的浏览器上的 Angular Service Worker [英] Angular Service Worker on the browsers that do not support it

查看:32
本文介绍了不支持它的浏览器上的 Angular Service Worker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular 团队做得很好,并在版本 5 中引入了 Service Worker 支持.文档 非常有帮助,在阅读相关文章后,我真的可以看到事情将如何运作,但是那里没有涵盖一个主题.这一切在不支持 Service Worker 的浏览器中是如何工作的.

Angular team made a great job and introduced service workers support in the version 5. The documentation is quite helpful and I can really see how the things will work right after reading the related articles, however there is one topic that is not covered there. How does this all work in the browsers that do not support service workers.

内容是这样的:

您的应用程序必须在支持服务的网络浏览器中运行工人.目前,Chrome 和 Firefox 的最新版本是支持的.了解其他作为 Service Worker 的浏览器准备好,请参阅我可以使用页面.

Your application must run in a web browser that supports service workers. Currently, the latest versions of Chrome and Firefox are supported. To learn about other browsers that are service worker ready, see the Can I Use page.

Can I Use 显示对该功能在相对重要的浏览器中的支持很差.我可以在不工作的 IE11 中幸存下来,但 Safari(尤其是移动设备)是我不希望保持不受支持的东西.

Can I Use shows quite a poor support of the feature in relatively important browsers. I can survive the not working IE11, but Safari (especially mobile) is a thing I wouldn't like to keep unsupported.

因此,我的目的是了解 Angular Service Worker 模块、服务、这些服务提供的事件等在支持 Service Worker 的浏览器上的表现.

So, my intention would be to know how the angular service worker module, services, events those services provide etc will behave on the browser that does not support service workers.

所有这些都会默默地失败吗?无论如何都会触发事件吗?会请求 ngsw-worker.js 吗?某些内容会缓存在 IndexedDB 中而不是 Service Worker 中吗?

Will all those just silently fail? Will the events be triggered anyhow? Will the ngsw-worker.js be requested? Will something be cached in IndexedDB instead of service worker?

解决方案看起来很酷,但是我无法回答问题我应该使用它吗?直到我知道上述问题的答案.

The solution looks cool, however I cannot answer the question should I use it? until I know the answers on the questions above.

推荐答案

The官方回应

Angular SW 仅适用于支持 Service Worker 的浏览器.这包括所有应用程序集成(例如 SwUpdate 服务).

The Angular SW only works in browsers which support service workers. This includes all of the application integration (e.g. the SwUpdate service).

如果当前浏览器不支持 SW.

If SWs are unsupported in the current browser.

  • 永远不会下载 SW 脚本和 ngsw.json.
  • 主动尝试与软件交互,例如调用 -
  • SwUpdate.checkForUpdate() 将返回被拒绝的承诺.
  • 被动尝试监听 SW Observables(例如 SwUpdate.available)将永远不会触发 - Observables 永远不会发出.

这篇关于不支持它的浏览器上的 Angular Service Worker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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