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
|
// Change version to cause cache refresh, sw.js SE NE SME CACHAT aka ne ga dat v assets!
const static_cache_name = "site-static-v0.0.7";
const assets = [
"./",
"./courbd.ttf",
"./favicon.ico",
"./favicon.png",
"./iso-8859-2.js",
"./myriadpro.otf",
"./myriadpro-semibold.otf",
"./qr.html",
"./qrcode.js",
"./qrcode.tosjis.js",
"./upn.html",
"./upn.svg",
"./index.html",
"./512x512.png",
"./192x192.png",
"./manifest.json"
];
self.addEventListener("install", (evt) => {
evt.waitUntil(
caches.open(static_cache_name).then((cache) => {
cache.addAll(assets);
})
);
});
// Delete old caches
self.addEventListener("activate", evt => {
evt.waitUntil(
caches.keys().then((keys) => {
return Promise.all(keys
.filter(key => key !== static_cache_name)
.map(key => caches.delete(key))
);
})
);
});
self.addEventListener("fetch", (evt) => {
evt.respondWith(caches.match(evt.request).then((cache_res) => {
return cache_res || fetch(evt.request);
}))
});
|