Service Worker Sample: Detailed Registration

Available in Chrome 40+

This sample provides some insight into the events involved in a typical service worker registration. The script service-worker.js is registered to handle the URL scope ./. It is "safe" to register the same script multiple times, so it's not necessary to check for a previous registration.

Various pieces of information about the service worker from the perspective of the registering page can be found below. Additionally, visit chrome://inspect/#service-workers and click on the "inspect" link below the registered service worker to view logging statements for the various actions the service-worker.js script is performing.

Service Worker Availability

Service Workers available in your browser. (Whether 'serviceWorker' in navigator.)

Is This Page Controlled by a Service Worker?

This page currently controlled. (Whether navigator.serviceWorker.controller is set.)

Info about the Current Registration

The navigator.serviceWorker.register() call .

The current registration represents the service worker.

Tip: With a newly registered service worker in the activated state, refresh the page to have the service worker take control. You can also refresh with the Shift key held down to load the page without the service worker controlling it.

State transitions of the service worker associated with the current registration: