diff --git a/public/sw.js b/public/sw.js
index 797f73a..2fcbc7d 100644
--- a/public/sw.js
+++ b/public/sw.js
@@ -1,10 +1,12 @@
const addResourcesToCache = async (resources) => {
- const cache = await caches.open('v1');
+ const cache = await caches.open('cozy-reader-app-v1');
+ console.log('adding resources to cache...', resources)
await cache.addAll(resources);
};
const putInCache = async (request, response) => {
- const cache = await caches.open('v1');
+ const cache = await caches.open('cozy-reader-app-v1');
+ console.log('adding one response to cache...', request)
await cache.put(request, response);
};
@@ -59,25 +61,27 @@ const enableNavigationPreload = async () => {
};
self.addEventListener('activate', (event) => {
+ console.log('activating...', event)
event.waitUntil(enableNavigationPreload());
});
self.addEventListener('install', (event) => {
+ console.log('installing...', event)
event.waitUntil(
addResourcesToCache([
'./',
- './index.html',
- './favicon.ico'
+ './favicon.ico',
])
);
});
self.addEventListener('fetch', (event) => {
+ console.log('fetch happened', event.request)
event.respondWith(
cacheFirst({
request: event.request,
preloadResponsePromise: event.preloadResponse,
- fallbackUrl: './index.html',
+ fallbackUrl: './',
})
);
});
\ No newline at end of file
diff --git a/src/pages/index.astro b/src/pages/index.astro
index c455713..3c8727f 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -40,10 +40,26 @@ if (url)
\ No newline at end of file