Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
Latest commit
48 lines (43 loc) · 1.04 KB
/
Copy pathsw.js
File metadata and controls
48 lines (43 loc) · 1.04 KB
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
// Register service worker and files to be cached
self.addEventListener('install',function(e){
e.waitUntil(
caches.open('shadowscript2').then(function(cache){
returncache.addAll([
'./',
'./index.html',
'./index.html?homescreen=1',
'./?homescreen=1',
'../css/master.css',
'../css/semantic.min.css',
'../js/master.js',
'../js/semantic.min.js',
'../js/typed.js',
'../assets/images/binary.jpg',
'../assets/images/binaryred.jpg'
]);
})
);
});
self.addEventListener('fetch',function(event){
console.log(event.request.url);
event.respondWith(
caches.match(event.request).then(function(response){
returnresponse||fetch(event.request);
})
);
});
// Delete old service workers
self.addEventListener('activate',function(event){
varcacheWhitelist=['shadowscript2'];
event.waitUntil(
caches.keys().then(function(cacheNames){
returnPromise.all(
cacheNames.map(function(cacheName){
if(cacheWhitelist.indexOf(cacheName)===-1){
returncaches.delete(cacheName);
}
})
);
})
);
});