Created
August 17, 2017 06:32
-
-
Save uglow/8351268fa5339d3ffbf0a0891f34dc3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
importScripts('workbox-sw.prod.v1.3.0.js'); | |
const workbox = new WorkboxSW(); | |
const cacheFirstStrategy = workbox.strategies.cacheFirst(); | |
const networkFirstStrategy = workbox.strategies.networkFirst({networkTimeoutSeconds: 10}); | |
// Go to the network first for APIs, then to the cache | |
workbox.router.registerRoute('http*://*/api/*', networkFirstStrategy, 'GET'); | |
// Cache the external fonts | |
workbox.router.registerRoute('https://fonts.gstatic.com/*', cacheFirstStrategy); | |
// Cache the ionicons.woff2?v... file (querystring prevents cache-hit) | |
workbox.router.registerRoute('/assets/fonts/*', cacheFirstStrategy); | |
// The precache array will be populated by workbox-cli. See package.json | |
workbox.precache([ | |
// ... list of static files here | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment