forked from petanikode/belajar-git
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
32 lines (30 loc) · 756 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
const version = "0.1.1";
const cacheName = `belajar-git-${version}`;
self.addEventListener('install', e => {
e.waitUntil(
caches.open(cacheName).then(cache => {
return cache.addAll([
`/`,
`/index.html`,
`/login.html`,
`/register.html`,
`/about.html`,
'/contact.html',
`/ico.png`
])
.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);
})
);
});