-
Notifications
You must be signed in to change notification settings - Fork 0
/
sw.js
35 lines (32 loc) · 789 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
const CACHE = "sw-cache";
var fileList = [
"./",
"./assets/css/small.css",
"./assets/css/style.css",
"./assets/images/empty.png",
"./assets/images/logo.svg",
"./assets/js/helpers.js",
"./assets/js/idb.js",
"./assets/js/script.js",
"./assets/manifest.json",
"./favicon.ico",
"./index.html",
"./sw.js"
];
self.addEventListener("install", (e) => {
e.waitUntil((async () => {
const cache = await caches.open(CACHE);
await cache.addAll(fileList);
self.skipWaiting();
})());
});
self.addEventListener("activate", (e) => {
e.waitUntil((async () => {
self.clients.claim();
})());
});
self.addEventListener("fetch", (e) => {
e.respondWith((async () => {
return fetch(e.request).catch(async () => await caches.match(e.request));
})());
});