feat: Add now page for Jan
All checks were successful
Build Docker / BuildImage (push) Successful in 46s

This commit is contained in:
2025-01-30 13:00:28 +11:00
parent 1fd539bcb9
commit 7bea502bdf
3 changed files with 164 additions and 33 deletions

View File

@@ -35,36 +35,3 @@ self.addEventListener('install', async (event) => {
.then((cache) => cache.addAll(PRECACHE_ASSETS))
);
});
if (workbox.navigationPreload.isSupported()) {
workbox.navigationPreload.enable();
}
workbox.routing.registerRoute(
new RegExp('/*'),
new workbox.strategies.StaleWhileRevalidate({
cacheName: CACHE
})
);
self.addEventListener('fetch', (event) => {
if (event.request.mode === 'navigate') {
event.respondWith((async () => {
try {
const preloadResp = await event.preloadResponse;
if (preloadResp) {
return preloadResp;
}
const networkResp = await fetch(event.request);
return networkResp;
} catch (error) {
const cache = await caches.open(CACHE);
const cachedResp = await cache.match('/404');
return cachedResp;
}
})());
}
});