diff --git a/webapp/sw.js b/webapp/sw.js index 6be1d33..1dc322b 100644 --- a/webapp/sw.js +++ b/webapp/sw.js @@ -1,4 +1,4 @@ -const CACHE_NAME = 'podcast-mindmap-v1'; +const CACHE_NAME = 'podcast-mindmap-v2'; // Core assets to cache immediately const CORE_ASSETS = [ @@ -45,6 +45,21 @@ self.addEventListener('fetch', event => { return; } + // App shell (index.html): network-first, sonst kommen Code-Updates erst beim + // uebernaechsten Reload an. Cache-Fallback bleibt fuer Offline-Betrieb erhalten. + if (url.pathname === '/' || url.pathname === '/index.html') { + event.respondWith( + fetch(event.request).then(resp => { + if (resp.ok) { + const clone = resp.clone(); + caches.open(CACHE_NAME).then(cache => cache.put(event.request, clone)); + } + return resp; + }).catch(() => caches.match(event.request)) + ); + return; + } + // Audio files: network-first, cache on success (optional offline playback) if (url.pathname.startsWith('/audio/')) { event.respondWith(