-
Notifications
You must be signed in to change notification settings - Fork 30
/
sw.js
37 lines (32 loc) · 769 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
const CACHE_NAME = "gen-brand-photo-pictrue-res";
self.addEventListener("install", (event) => {
self.skipWaiting();
event.waitUntil(
caches
.open(CACHE_NAME)
.then((cache) =>
cache.addAll([
"./",
"./index.html",
"./index.js",
"./index.css",
"./simple.jpg",
"./pkg/gen_brand_photo_pictrue.js",
"./pkg/gen_brand_photo_pictrue_bg.wasm",
])
)
);
});
self.addEventListener("activate", (event) => {
clients.claim();
});
self.addEventListener("fetch", (event) => {
return event.respondWith(
caches.match(event.request).then((cacheData) => {
if (cacheData) {
return cacheData;
}
return fetch(event.request);
})
);
});