-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
38 lines (33 loc) · 932 Bytes
/
sw.js
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
28
29
30
31
32
33
34
35
36
37
38
console.log('Hello from service-worker.js');
self.addEventListener('install', e => {
e.waitUntil(
caches.open('snake').then(cache => {
return cache.addAll([
'',
'/',
'index.html',
'manifest.json',
'css/main.css',
'src/script.js',
'fonts/JAGUAR.ttf',
'src/snake.js',
'src/icons/icon@96.png',
'src/icons/icon@128.png',
'src/icons/icon@256.png',
'https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.5/p5.js',
'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.2/lodash.js',
])
.then(() => self.skipWaiting());
})
)
});
self.addEventListener('activate', event => {
event.waitUntil(self.clients.claim());
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request).then(response => {
return response || fetch(event.request);
})
);
});