-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
27 lines (24 loc) · 772 Bytes
/
Copy pathsw.js
File metadata and controls
27 lines (24 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const CACHE_NAME = 'roulette-phone-v1';
const ASSETS = [
'./',
'./index.html',
'./manifest.webmanifest',
'./favicon.svg',
'./icons/icon-192.png',
'./icons/icon-512.png',
'./icons/apple-touch-icon.png'
];
self.addEventListener('install', event => {
event.waitUntil(caches.open(CACHE_NAME).then(cache => cache.addAll(ASSETS)));
self.skipWaiting();
});
self.addEventListener('activate', event => {
event.waitUntil(
caches.keys().then(keys => Promise.all(keys.filter(key => key !== CACHE_NAME).map(key => caches.delete(key))))
);
self.clients.claim();
});
self.addEventListener('fetch', event => {
if (event.request.method !== 'GET') return;
event.respondWith(caches.match(event.request).then(cached => cached || fetch(event.request)));
});