Skip to content
学习 衡量 博客 Case studies 关于
本页内容
  • Lighthouse 服务工作进程审计如何失败
  • 如何注册服务工作进程
  • 资源

不注册可控制页面和“start_url”的服务工作进程

May 4, 2019 — 更新日期 Jun 10, 2020
Available in: Español, 日本語, 한국어, Português, Русский, English
Appears in: PWA 审核
本页内容
  • Lighthouse 服务工作进程审计如何失败
  • 如何注册服务工作进程
  • 资源

注册服务工作进程是启用以下关键渐进式 Web 应用程序 (PWA) 特性的第一步:

  • 离线工作
  • 支持推送通知
  • 可以安装到设备

有关更多信息,请参阅文章服务工作进程和缓存存储 API。

浏览器兼容性 #

除 Internet Explorer 外的所有主流浏览器都支持服务工作进程。请参阅浏览器兼容性。

Lighthouse 服务工作进程审计如何失败 #

Lighthouse 会标记不注册服务工作进程的页面:

Lighthouse 审计显示网站不注册服务工作进程

Lighthouse 检查 Chrome 远程调试协议是否返回一个服务工作进程版本。如果不返回,则审计失败。

In the Lighthouse report UI the full PWA badge is given when you pass all of the audits in all of the PWA subcategories (Fast and reliable, Installable, and PWA optimized).

如何注册服务工作进程 #

成功

Workbox is the recommended approach for adding service workers to websites because it automates a lot of boilerplate, makes it easier to follow best practices, and prevents subtle bugs that are common when using the low-level ServiceWorker API directly.

注册服务工作进程只需几行代码,但使用服务工作进程的唯一原因是可以实现上述 PWA 特性之一。实际上,实现这些特性需要更多工作:

  • 要了解如何缓存文件以供离线使用,请参阅文章什么是网络可靠性以及如何进行测量?。
  • 要了解如何使应用程序可安装,请参阅使其可安装 codelab。
  • 要了解如何启用推送通知,请参阅 Google 的向 Web 应用程序添加推送通知。

资源 #

  • 不注册可控制页面和 start_url 的服务工作进程审计的源代码
  • 服务工作进程:简介
  • 服务工作进程和缓存存储 API
  • 什么是网络可靠性以及如何进行测量?
  • 使其可安装
  • 向 Web 应用程序添加推送通知
Last updated: Jun 10, 2020 — Improve article
Return to all articles
分享
订阅

Contribute

  • 提交错误
  • 查看源代码

相关内容

  • developer.chrome.com
  • Chrome 动态
  • 网站开发基础
  • 案例研究
  • 播客
  • 节目

连接

  • Twitter
  • YouTube
  • Google Developers
  • Chrome
  • Firebase
  • Google Cloud Platform
  • 所有产品
  • 条款和隐私权
  • 社区准则

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies.