Created
January 7, 2018 21:37
-
-
Save Danetag/6797f8046a42e41c36ce0689739ecf18 to your computer and use it in GitHub Desktop.
Part of service-worker
This file contains hidden or 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
// On fetch | |
// ... | |
if (event.request.headers.get('accept').includes('text/html')) { | |
event.respondWith(toolbox.networkFirst(event.request)); | |
return; | |
} | |
// ... | |
// Runtime cache configuration, using the sw-toolbox library. | |
toolbox.router.get(/^https:\/\/images\.contentful\.com/, toolbox.cacheFirst, {}); | |
toolbox.router.get(/^https:\/\/images\.ctfassets\.net/, toolbox.cacheFirst, {}); | |
toolbox.router.get(/^https:\/\/videos\.contentful\.com/, toolbox.cacheFirst, {}); | |
toolbox.router.get(/^https:\/\/videos\.ctfassets\.net/, toolbox.cacheFirst, {}); | |
toolbox.router.get(/^https:\/\/assets\.contentful\.com/, toolbox.cacheFirst, {}); | |
toolbox.router.get(/^https:\/\/assets\.ctfassets\.net/, toolbox.cacheFirst, {}); | |
toolbox.router.get(/^https:\/\/downloads\.contentful\.com/, toolbox.cacheFirst, {}); | |
toolbox.router.get(/^https:\/\/downloads\.ctfassets\.net/, toolbox.cacheFirst, {}); | |
toolbox.router.get(/^https:\/\/www\.chobani\.com/, toolbox.networkFirst, {}); | |
toolbox.router.get(/^https:\/\/s3\.amazonaws\.com/, toolbox.fastest, {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment