Created
October 28, 2019 14:48
-
-
Save thepassle/d8ab0d619726a442b1826941635bd27b to your computer and use it in GitHub Desktop.
clientsclaim9
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
self.addEventListener('install', event => { | |
// cache a cat SVG | |
event.waitUntil( | |
caches.open('static-v1') | |
.then(cache => cache.add('cat.svg')) | |
); | |
}); | |
self.addEventListener('activate', event => { | |
clients.claim(); | |
console.log('Now controlling the page!'); | |
}); | |
self.addEventListener('fetch', event => { | |
if (url.pathname.endsWith('/dog.svg')) { | |
event.respondWith(caches.match('cat.svg')); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment