-
Notifications
You must be signed in to change notification settings - Fork 1
/
serviceWorker.js
50 lines (31 loc) · 915 Bytes
/
serviceWorker.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
39
40
41
42
43
44
45
46
47
48
49
50
const cacheName = 'TODO';
const assets = [
'./',
'./index.html',
'./index.js',
'./style.css',
'./manifest.json',
'./serviceWorker.js',
'https://img.icons8.com/stickers/100/000000/task.png',
'https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css',
'https://fonts.googleapis.com/icon?family=Material+Icons',
'https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js',
'https://code.jquery.com/jquery-3.2.1.min.js',
'https://cdn.jsdelivr.net/npm/vue@2.7.0'
]
self.addEventListener('install', e => {
e.waitUntil(
caches.open(cacheName).then(cache => {
return cache.addAll(assets);
})
);
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.open(cacheName)
.then(cache => cache.match(event.request, { ignoreSearch: true }))
.then(response => {
return response || fetch(event.request);
})
);
});