-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
34 lines (31 loc) · 819 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
const filesToCache = [
'static/css/bootstrap.css',
'static/icons/192.png',
'static/icons/512.png',
'static/js/index.js',
'static/js/service.js',
'static/manifest.json',
'index.html',
'static/css/bootstrap.css.map',
'static/js/bootstrap.min.js',
'static/js/bootstrap.min.js.map',
'static/icons/icon.ico',
'/sw.js'
];
const staticCacheName = 'Notify-cache';
self.addEventListener('install', event => {
console.log('Attempting to install service worker and cache static assets');
event.waitUntil(
caches.open(staticCacheName)
.then(cache => {
return cache.addAll(filesToCache);
})
);
});
self.addEventListener('fetch', e => {
e.respondWith(
caches.match(e.request).then(response => {
return response || fetch(e.request)
})
)
})