ページと start_url を制御するサービスワーカーが登録されない

公開日 更新日

翻訳先言語: English, Español, Português, 한국어, 中文, Pусский

Service Worker の登録は、Progressive Web App (PWA) (プログレッシブウェブアプリ) が提供する主な機能を有効化する最初のステップです。

  • オフラインで稼働する
  • プッシュ通知をサポートする
  • デバイスにインストールできる

詳細は、Service workers and the Cache Storage API (サービスワーカーと Cache Storage API) と題した記事をお読みください。

ブラウザの互換性

サービスワーカーは、Internet Explorer を除くすべての主要なブラウザーでサポートされています。Browser compatibility (ブラウザの互換性) を参照してください。

Lighthouse のサービスワーカー監査が失敗する原因

Lighthouse は、サービスワーカーを登録しないページをフラグします。

サイトがサービスワーカーを登録しないことを示す Lighthouse 監査

Lighthouse は、Chrome Remote Debugging Protocol (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).

サービスワーカーの登録方法

Success

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 の機能の 1 つを実装できるようにするためです。実際にそうした機能を実装するには、さらに多くの作業が必要になります。

リソース

更新日 記事を改善する

This site uses cookies to deliver and enhance the quality of its services and to analyze traffic. If you agree, cookies are also used to serve advertising and to personalize the content and advertisements that you see. Learn more about our use of cookies.