fix: SW staleWhileRevalidate gibt nie undefined zurück (verhindert Promise-Rejection)
Wenn weder Cache noch Netzwerk verfügbar sind gab die Funktion undefined zurück, was event.respondWith() als Promise-Rejection wertet und einen Network Error im Browser erzeugt. Letzter Ausweg ist jetzt eine 503-Antwort. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+8
-4
@@ -12,9 +12,9 @@
|
||||
* API: Immer Netzwerk (kein Caching von Nutzerdaten)
|
||||
*/
|
||||
|
||||
const SHELL_CACHE = 'oikos-shell-v8';
|
||||
const PAGES_CACHE = 'oikos-pages-v8';
|
||||
const ASSETS_CACHE = 'oikos-assets-v8';
|
||||
const SHELL_CACHE = 'oikos-shell-v9';
|
||||
const PAGES_CACHE = 'oikos-pages-v9';
|
||||
const ASSETS_CACHE = 'oikos-assets-v9';
|
||||
const ALL_CACHES = [SHELL_CACHE, PAGES_CACHE, ASSETS_CACHE];
|
||||
|
||||
// App-Shell: sofort benötigt für ersten Render
|
||||
@@ -152,8 +152,12 @@ async function staleWhileRevalidate(request, cacheName) {
|
||||
|
||||
// Offline-Fallback: SPA-Shell für Navigation
|
||||
if (request.mode === 'navigate') {
|
||||
return caches.match('/index.html');
|
||||
const shell = await caches.match('/index.html');
|
||||
if (shell) return shell;
|
||||
}
|
||||
|
||||
// Letzter Ausweg: leere 503-Antwort statt Promise-Rejection
|
||||
return new Response('Service unavailable', { status: 503 });
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user