-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsw.js
More file actions
47 lines (44 loc) · 1.09 KB
/
sw.js
File metadata and controls
47 lines (44 loc) · 1.09 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
const version = '4'
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open(version).then(function(cache) {
return cache.addAll([
'/',
'/manifest.json',
'/index.html',
'/css/main.css',
'/js/main.js',
'/img/logo.svg',
'/img/mask.jpg',
'/img/work-bg-white.jpg',
'/img/work-bg-teal.jpg',
'/img/work-bg-orange.jpg',
'/img/work-bg-yellow.jpg',
'https://rsms.me/inter/inter.css',
]);
})
);
});
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
if (response) {
return response;
}
return fetch(event.request);
})
)
});
self.addEventListener('activate', function(event) {
event.waitUntil(
caches.keys().then(function(cacheNames) {
return Promise.all(
cacheNames.filter(function(cacheName) {
return cacheName != version;
}).map(function(cacheName) {
return caches.delete(cacheName);
})
);
})
);
});