fix(sw): network-first + 3s timeout statt SWR fuer Daten
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 30s

SWR lieferte bei jedem Cache-Hit sofort die alte Antwort und
aktualisierte das Cache nur fuer den naechsten Request. Folge:
UI zeigte stale Daten, frische Daten erst nach Refresh.

Neu: network-first mit 3 s Timeout-Fallback. Netz gewinnt bei
frischer Antwort; Timeout oder Netzwerk-Fehler fallen auf Cache
zurueck. Pre-Cache-Logik (runSync) bleibt unveraendert, Shell
und Bilder bleiben cache-first.
This commit is contained in:
hsiegeln
2026-04-20 08:29:00 +02:00
parent b5c01b950e
commit 633e497bdc
5 changed files with 47 additions and 22 deletions

View File

@@ -1,4 +1,4 @@
export type CacheStrategy = 'shell' | 'swr' | 'images' | 'network-only';
export type CacheStrategy = 'shell' | 'network-first' | 'images' | 'network-only';
type RequestShape = { url: string; method: string };
@@ -37,6 +37,7 @@ export function resolveStrategy(req: RequestShape): CacheStrategy {
return 'shell';
}
// Everything else: recipe pages, API reads, lists — all SWR.
return 'swr';
// Everything else: recipe pages, API reads, lists — network-first with
// timeout fallback to cache (handled in service-worker.ts).
return 'network-first';
}