fix: bypass service worker cache for dynamic /api/ endpoints, resolving stale favorites cache
All checks were successful
Build & Push Docker Image to Gitea Registry / build-and-push (push) Successful in 13s

This commit is contained in:
Kroonk
2026-05-22 00:23:37 +02:00
parent b0bcc8abbd
commit 8ebee64543
3 changed files with 11 additions and 4 deletions

10
sw.js
View File

@@ -1,4 +1,4 @@
const CACHE_NAME = 'mischlabs-pwa-v25';
const CACHE_NAME = 'mischlabs-pwa-v26';
const APP_SHELL = [
'/',
'/index.html',
@@ -6,7 +6,7 @@ const APP_SHELL = [
'/offline.html',
'/style.css?v=33',
'/auth.js?v=2',
'/app.js?v=39',
'/app.js?v=40',
'/favorites.js?v=1',
'/services.json?v=1',
'/manifest.webmanifest?v=4',
@@ -41,6 +41,12 @@ self.addEventListener('fetch', (event) => {
return;
}
// Do not intercept or cache API requests
const url = new URL(request.url);
if (url.pathname.startsWith('/api/')) {
return;
}
if (request.mode === 'navigate') {
event.respondWith(
fetch(request).catch(() => caches.match('/offline.html'))