-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsw.js
38 lines (36 loc) · 1.03 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
const version = "0.0.11";
const cacheName = `balta-${version}`;
self.addEventListener('install', e => {
e.waitUntil(
caches.open(cacheName).then(cache => {
return cache.addAll([
`/`,
`/images/logo-2-branco.png`,
`/images/icons/icon-72x72.png`,
`/images/icons/icon-96x96.png`,
`/images/icons/icon-128x128.png`,
`/images/icons/icon-144x144.png`,
`/images/icons/icon-152x152.png`,
`/images/icons/icon-192x192.png`,
`/images/icons/icon-384x384.png`,
`/images/icons/icon-512x512.png`,
`/favicon.ico`,
`/index.html`,
`/styles.css`,
])
.then(() => self.skipWaiting());
})
);
});
self.addEventListener('activate', event => {
event.waitUntil(self.clients.claim());
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.open(cacheName)
.then(cache => cache.match(event.request, {ignoreSearch: true}))
.then(response => {
return response || fetch(event.request);
})
);
});