Service Worker Sample: Selective Caching

Available in Chrome 40+

This sample demonstrates basic service worker registration, in conjunction with selective caching.

In this case, we're caching all font resources by checking for responses with a Content-Type header that starts with font/. The same principle can be extended to selectively cache any category of content based on request or response headers (assuming the response is non-opaque).

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.