--- feature_name: Basic Service Worker chrome_version: 40 feature_id: 6561526227927040 local_css_files: ['styles.css'] ---

Background

This sample demonstrates a basic service worker that could be used as-is, or as a starting point for further customization.

What It Does

You can confirm the service worker's behavior using the Application panel of Chrome's DevTools.

What It Doesn't Do

Live Demo

The following demo illustrates the service worker's runtime caching by loading images in response to clicking the button below.

The first time a given image is requested, the service worker will be load it from the network, but each subsequent time, it will be retrieved from the cache.

{% include js_snippet.html filename='demo.js' %} {% include js_snippet.html filename='service-worker.js' displayonly=true title="Service Worker's JavaScript" %}