2023-05-17 02:15:10 +00:00
|
|
|
const CACHE_NAME = 'kifu-pwa-3';
|
2023-04-20 15:07:41 +00:00
|
|
|
|
|
|
|
self.addEventListener('install', event => {
|
|
|
|
event.waitUntil((async () => {
|
|
|
|
const cache = await caches.open(CACHE_NAME);
|
|
|
|
cache.addAll([
|
|
|
|
'/',
|
2023-05-07 17:13:20 +00:00
|
|
|
'/kifu-bundle.js',
|
2023-05-13 16:29:57 +00:00
|
|
|
'/kifu.css',
|
2023-04-20 15:07:41 +00:00
|
|
|
]);
|
|
|
|
})());
|
|
|
|
});
|
|
|
|
|
|
|
|
self.addEventListener('fetch', event => {
|
|
|
|
event.respondWith((async () => {
|
|
|
|
const cache = await caches.open(CACHE_NAME);
|
|
|
|
const cachedResponse = await cache.match(event.request);
|
|
|
|
if (cachedResponse) {
|
|
|
|
return cachedResponse;
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
const fetchResponse = await fetch(event.request);
|
|
|
|
cache.put(event.request, fetchResponse.clone());
|
|
|
|
return fetchResponse;
|
|
|
|
} catch (e) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})());
|
|
|
|
});
|