-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
41 lines (35 loc) · 948 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
// Service Work
var cacheName = 'v1.0';
var cacheAssets = [
'/',
'/index.html',
'/sobre/index.html',
'/links/index.html',
'/notes/index.html',
'/javascript/app.js',
'/sw.js',
'/css/main.css',
'/fonts/CircularStd-Book.woff2'
]
// installation
self.addEventListener('install', e => {
console.log('Service Worker: Installed');
e.waitUntil(
caches
.open(cacheName)
.then(cache => {
console.log('Service Worker: Caching Files');
cache.addAll(cacheAssets);
})
.then(() => self.skipWaiting())
);
});
// activation
self.addEventListener('activate', e => {
console.log('Service Worker: Installed');
});
// fetch
self.addEventListener('fetch', e => {
console.log('Service Worker: Fetching');
e.respondWith(fetch(e.request).catch(() => caches.match(e.request)));
});