Skip to content

Instantly share code, notes, and snippets.

@caraya
Created April 25, 2016 02:34
Show Gist options
  • Save caraya/70f93f12b1588cd8f48a721136b8164d to your computer and use it in GitHub Desktop.
Save caraya/70f93f12b1588cd8f48a721136b8164d to your computer and use it in GitHub Desktop.
global => {
'use strict';
// Load the sw-toolbox library.
importScripts('bower_components/sw-toolbox/sw-toolbox.js');
// Turn on debug logging, visible in the Developer Tools' console.
global.toolbox.options.debug = true;
// By default, all requests will use the toolbox.networkFirst cache
// strategy, and their responses will be stored in the default cache.
global.toolbox.router.default = global.toolbox.networkFirst;
// Boilerplate to ensure our service worker takes control of the page as soon
// as possible.
global.addEventListener('install',
event => event.waitUntil(global.skipWaiting()));
global.addEventListener('activate',
event => event.waitUntil(global.clients.claim()));
})(self);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment