forked from hunghg255/linktree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserviceWorker.js
40 lines (38 loc) · 1000 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
const staticDevCoffee = 'giahungv1';
const assets = [
'/',
'/index.html',
'/service.js',
'/assets/css/style.css',
'/assets/js/main.js',
'/assets/images/avatar.jpeg',
'/assets/images/call.svg',
'/assets/images/email.svg',
'/assets/images/facebook.svg',
'/assets/images/github.svg',
'/assets/images/instagram.svg',
'/assets/images/linkedin.svg',
'/assets/images/qr-code.png',
'/assets/images/qrhung.png',
'/assets/images/H16.png',
'/assets/images/H24.png',
'/assets/images/H32.png',
'/assets/images/H64.png',
'/assets/images/H128.png',
'/assets/images/H256.png',
'/assets/images/H512.png',
];
self.addEventListener('install', (installEvent) => {
installEvent.waitUntil(
caches.open(staticDevCoffee).then((cache) => {
cache.addAll(assets);
})
);
});
self.addEventListener('fetch', (fetchEvent) => {
fetchEvent.respondWith(
caches.match(fetchEvent.request).then((res) => {
return res || fetch(fetchEvent.request);
})
);
});