Skip to content

Instantly share code, notes, and snippets.

@deanhume
Created July 27, 2017 06:31
Show Gist options
  • Save deanhume/e5b8e0af6fad706bc04a04c0377efdf1 to your computer and use it in GitHub Desktop.
Save deanhume/e5b8e0af6fad706bc04a04c0377efdf1 to your computer and use it in GitHub Desktop.
Workbox Caching Example
importScripts('workbox-sw.prod.v1.1.0.js');
const workboxSW = new self.WorkboxSW();
workboxSW.precache(fileManifest);
// The route for any requests from the googleapis origin
workboxSW.router.registerRoute('https://fonts.googleapis.com/(.*)',
workboxSW.strategies.cacheFirst({
cacheName: 'googleapis',
cacheableResponse: {
statuses: [0, 200]
},
networkTimeoutSeconds: 4
})
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment