-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
79 lines (65 loc) · 1.44 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
var CACHE_NAME = 'static-v1';
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open(CACHE_NAME).then(function(cache) {
return cache.addAll([
'./',
'./index.html',
'./icon.png',
'./estilo.css',
'./index.js',
'./manifest.json',
'./bootstrap.min.css',
]);
})
);
});
/* Cache on install
this.addEventListener("install", event => {
this.skipWaiting();
event.waitUntil(
caches.open(staticCacheName)
.then(cache => {
return cache.addAll(filesToCache);
})
)
}); */
self.addEventListener('fetch', function(e) {
console.log(e.request.url);
e.respondWith(
caches.match(e.request).then(function(response) {
return response || fetch(e.request);
})
);
});
self.addEventListener('activate', function activator(event) {
event.waitUntil(
caches.keys().then(function (keys) {
return Promise.all(keys
.filter(function (key) {
return key.indexOf(CACHE_NAME) !== 0;
})
.map(function (key) {
return caches.delete(key);
})
);
})
);
});
/*
var CACHE_NAME = 'static-v1';
self.addEventListener('install', function(e) {
e.waitUntil(
caches.open(CACHE_NAME).then(function(cache) {
return cache.addAll([
'/',
'/index.html',
'/estilo.css',
'/index.js',
'/manifest.json',
'/bootstrap.min.css',
]);
})
);
});
*/