Skip to content

Instantly share code, notes, and snippets.

@thepassle
Created October 28, 2019 14:48
Show Gist options
  • Save thepassle/d8ab0d619726a442b1826941635bd27b to your computer and use it in GitHub Desktop.
Save thepassle/d8ab0d619726a442b1826941635bd27b to your computer and use it in GitHub Desktop.
clientsclaim9
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