-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsw.js
43 lines (39 loc) · 964 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
42
43
const version="191112.1";
const cacheName = "bus";
const files = [
"/",
"/index.html",
"/index.js",
"/elements.js",
"/style.css",
"/storage.js",
"/service.js",
"/dom.js",
"/img/cancel.svg",
"/img/gps.svg",
"/img/dial.svg",
"/img/star.svg",
"/img/update.svg"
];
self.addEventListener("install", e => {
console.log("[ServiceWorker] Install");
e.waitUntil(
caches.open(cacheName).then(cache => {
console.log("[ServiceWorker] Caching app shell");
return cache.addAll(files);
})
);
});
self.addEventListener("activate", event => {
console.log("Activate")
event.waitUntil(self.clients.claim());
});
self.addEventListener('fetch', event => {
console.log("FETCH",event)
event.respondWith(
caches.match(event.request, {ignoreSearch:true}).then(response => {
console.log("RESPONDING WITH",response,"OR",event.request)
return response || fetch(event.request);
})
);
});