Service-Worker: Cache-Version bumpen + index.html network-first
CACHE_NAME von v1 auf v2 erhoeht; activate-Handler loescht damit den alten Cache und liefert beim Reload die aktuelle index.html. Zusaetzlich laeuft '/' und '/index.html' jetzt network-first, sodass weitere Code-Updates schon beim naechsten Reload greifen statt erst beim uebernaechsten. Der Cache-Fallback bleibt fuer Offline-Betrieb. Hintergrund: Mit stale-while-revalidate fuer die App-Shell sah der Browser nach dem Mindmap-Fix weiterhin die kaputte index.html, weil die alte Version aus dem Cache kam und das Update erst im Hintergrund geholt wurde. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
121b51445b
commit
330b740573
17
webapp/sw.js
17
webapp/sw.js
@ -1,4 +1,4 @@
|
|||||||
const CACHE_NAME = 'podcast-mindmap-v1';
|
const CACHE_NAME = 'podcast-mindmap-v2';
|
||||||
|
|
||||||
// Core assets to cache immediately
|
// Core assets to cache immediately
|
||||||
const CORE_ASSETS = [
|
const CORE_ASSETS = [
|
||||||
@ -45,6 +45,21 @@ self.addEventListener('fetch', event => {
|
|||||||
return;
|
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)
|
// Audio files: network-first, cache on success (optional offline playback)
|
||||||
if (url.pathname.startsWith('/audio/')) {
|
if (url.pathname.startsWith('/audio/')) {
|
||||||
event.respondWith(
|
event.respondWith(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user