Created
December 25, 2018 16:07
-
-
Save stefanledin/a4e408db1fd8ff163fd0a545d57964f6 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('https://storage.googleapis.com/workbox-cdn/releases/3.6.1/workbox-sw.js'); | |
if (workbox) { | |
const cacheName = 'my-site-cache'; | |
workbox.routing.registerRoute( | |
'/', | |
workbox.strategies.networkFirst({ | |
cacheName | |
}) | |
); | |
workbox.routing.registerRoute( | |
/wp-content\/uploads/, | |
workbox.strategies.cacheFirst({ | |
cacheName | |
}) | |
); | |
workbox.routing.registerRoute( | |
/wp-content\/themes\/theme-name\/assets/, | |
workbox.strategies.staleWhileRevalidate({ | |
cacheName | |
}) | |
); | |
workbox.routing.registerRoute( | |
/cache\/autoptimize/, | |
workbox.strategies.staleWhileRevalidate({ | |
cacheName | |
}) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment