-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
29 lines (26 loc) · 755 Bytes
/
Copy pathsw.js
File metadata and controls
29 lines (26 loc) · 755 Bytes
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
var CACHE = 'ote-reader-v1';
var ASSETS = [
'./',
'./index.html',
'./styles.css',
'./app.js',
'./manifest.webmanifest',
'./demo-feed.json',
'./icon.svg'
];
self.addEventListener('install', function (event) {
event.waitUntil(caches.open(CACHE).then(function (cache) {
return cache.addAll(ASSETS);
}));
});
self.addEventListener('activate', function (event) {
event.waitUntil(caches.keys().then(function (keys) {
return Promise.all(keys.filter(function (key) { return key !== CACHE; }).map(caches.delete));
}));
});
self.addEventListener('fetch', function (event) {
if (event.request.method !== 'GET') return;
event.respondWith(fetch(event.request).catch(function () {
return caches.match(event.request);
}));
});