Service Worker Sample: Pre-fetching Resources During Registration (original) (raw)

Available inChrome 40+

This sample demonstrates basic service worker registration, in conjunction with pre-fetching of a list of specific resource URLs during the installation phase.

Visitchrome://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. Since most of the action takes place during the service worker's install handler, and that is only executed the very first time you visit this page (unless the service worker script changes), it can be helpful to inspect the logging in aChrome Incognito window.

Some of the resources below have been pre-fetched, and some haven't. Try disabling your network connection and clicking on all the links. The resources that have been pre-fetched should be served from the Service Worker's cache and display as expected; the resource that hasn't been pre-fetched will be unavailable.