-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserviceWorker.js
41 lines (39 loc) · 1.17 KB
/
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
const staticAssets = 'assets-v1';
const assets = [
'./',
'./index.html',
'./assets/bundle.css',
'./assets/bundle.js',
'./assets/vendor.js',
'./assets/images/banner/shape/shape-1.png',
'./assets/images/banner/shape/shape-2.png',
'./assets/images/banner/shape/shape-3.png',
'./assets/images/banner/shape/shape-4.png',
'./assets/images/banner/shape/shape-5.png',
'./assets/images/banner/shape/shape-6.png',
'./assets/images/work/project_360x360_1.jpg',
'./assets/images/work/project_360x360_2.jpg',
'./assets/images/work/project_360x360_3.jpg',
'./assets/images/work/project_360x360_4.jpg',
'./assets/images/work/project_360x360_5.jpg',
'./assets/images/work/project_360x360_6.jpg',
'./assets/images/call-to-action.jpg',
'./assets/images/favicon.png',
'./assets/images/map.png',
'./assets/images/picture.png',
'./assets/images/bullet.svg',
];
self.addEventListener('install', installEvent => {
installEvent.waitUntil(
caches.open(staticAssets).then(cache => {
cache.addAll(assets);
})
);
});
self.addEventListener('fetch', fetchEvent => {
fetchEvent.respondWith(
caches.match(fetchEvent.request).then(res => {
return res || fetch(fetchEvent.request);
})
);
});