diff options
Diffstat (limited to 'ui/service-worker.js')
| -rw-r--r-- | ui/service-worker.js | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/ui/service-worker.js b/ui/service-worker.js index e2143b3..9855a73 100644 --- a/ui/service-worker.js +++ b/ui/service-worker.js @@ -15,29 +15,29 @@ import { build, files, version } from '$service-worker'; const CACHE = `cache-${version}`; const ASSETS = [ - ...build, // the app itself - ...files // everything in `static` + ...build, // the app itself + ...files // everything in `static` ]; self.addEventListener('install', (event) => { - // Create a new cache and add all files to it - async function addFilesToCache() { - const cache = await caches.open(CACHE); - await cache.addAll(ASSETS); - } + // Create a new cache and add all files to it + async function addFilesToCache() { + const cache = await caches.open(CACHE); + await cache.addAll(ASSETS); + } - event.waitUntil(addFilesToCache()); + event.waitUntil(addFilesToCache()); }); self.addEventListener('activate', (event) => { - // Remove previous cached data from disk - async function deleteOldCaches() { - for (const key of await caches.keys()) { - if (key !== CACHE) await caches.delete(key); - } - } - - event.waitUntil(deleteOldCaches()); + // Remove previous cached data from disk + async function deleteOldCaches() { + for (const key of await caches.keys()) { + if (key !== CACHE) await caches.delete(key); + } + } + + event.waitUntil(deleteOldCaches()); }); // The simplest possible use of the caches above: @@ -47,8 +47,8 @@ async function cacheFirst(request) { return responseFromCache; } return fetch(request); -}; +} -self.addEventListener("fetch", (event) => { +self.addEventListener('fetch', (event) => { event.respondWith(cacheFirst(event.request)); }); |
