forked from PayButton/paybutton
-
Notifications
You must be signed in to change notification settings - Fork 1
/
serviceworker.js
43 lines (41 loc) · 981 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
// Cache contents on install
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('offline').then(function(cache) {
return cache.addAll(
[
'/css/styles.css',
'/css/buttons.css',
'/css/modal.css',
'/js/main.js',
'/js/qrjs2.js',
'/js/spicebutton.js',
'/js/urls.js',
'/index.html'
]
);
})
);
});
// Intercepts network calls to serve from cache if available
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});
/* // Remove outdated caches
self.addEventListener('activate', function(event) {
event.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.filter(function(offline) {
return true;
}).map(function(offline) {
return caches.delete(offline);
})
);
})
);
}); */