-
Notifications
You must be signed in to change notification settings - Fork 3
/
sw.js
41 lines (31 loc) · 905 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
35
36
37
38
39
40
41
self.addEventListener('install',succ=>{
console.log('install');
succ.waitUntil(
caches.open('c1').then(co=>{ return co.addAll(
[
'./',
'index.html',
'main.css',
'images/bg-01.jpg',
'main.js',
'manifest.json',
'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css',
'https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js',
'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'
]
)})
)})
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(resp) {
return resp || fetch(event.request).then(function(response) {
let responseClone = response.clone();
caches.open('c1').then(function(cache) {
cache.put(event.request, responseClone);
});
return resp
});
}).catch(function() {
})
);
});