-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsw.js
71 lines (62 loc) · 1.73 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
Developed by :
Dhimas Panjie Herlambang
https://github.com/DhimasPH
Ichwanul Fadhli
https://github.com/ichwanulfadhli/
Tangguh Destio Pramono
https://github.com/TangguhDP
API by :
Mathroid
https://github.com/mathdroid/indonesia-covid-19-api
Copyright (c) 2020 Dhimas P. Herlambang, Ichwanul Fadhli, Tangguh D. Pramono
*/
var cacheName = 'web-app-v2';
var staticAssets = [
'./',
'./index.html',
'./assets/style/hello-world.css',
'./index.js',
'./xhr.js',
'./images/COVID19_Wallpaper-ID.jpg',
'./images/kasus_corona.jpg',
'./images/scrolldown.gif',
'./images/self_isolate.png',
'./images/social_distancing.png',
'./images/use_tissue.png',
'./images/wash_hands.png',
'./images/wear_mask.png',
'./chart/highcharts.js',
'./chart/exporting.js',
'./chart/export-data.js',
'./chart/accessibility.js',
'./fonts/icomoon/style.css',
'./css/bootstrap.min.css',
'./css/aos.css',
'./css/style.css',
'./js/jquery-3.3.1.min.js',
'./js/jquery-migrate-3.0.1.min.js',
'./js/jquery.animateNumber.min.js',
'./js/aos.js',
'./js/main.js',
];
self.addEventListener('install', function (e) {
console.log('[ServiceWorker] Install');
e.waitUntil(
caches.open(cacheName).then(function (cache) {
console.log('[ServiceWorker] Caching app shell');
return cache.addAll(staticAssets);
})
);
});
self.addEventListener('activate', event => {
event.waitUntil(self.clients.claim());
caches.delete('web-app-v1');
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request, { ignoreSearch: true }).then(response => {
return response || fetch(event.request);
})
);
});