Background

This sample demonstrates basic service worker registration, in conjunction with pre-fetching of specific resource URLs during the installation phase. Additionally, it illustrates how window.caches can be used to make calls against the Cache Storage API from the context of a normal document. (This was previously only exposed to service workers.)

{% capture initial_output_content %}

The resources currently in the cache are listed below. Some initial files have been added via the service worker's install handler. You can add additional files to the cache or remove files from the context of the current page, without having to pass messages back and forth to the service worker.

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