From 8bafbf2ecee290a8a78be1e9538c5b4601523cac Mon Sep 17 00:00:00 2001 From: robin Date: Sat, 20 Dec 2025 23:22:02 +0100 Subject: [PATCH] feat: implement Paranoid Mode (SWR for Navigation) --- OFFLINE_SYNC_PWA.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OFFLINE_SYNC_PWA.md b/OFFLINE_SYNC_PWA.md index f154b9f..96e7c21 100644 --- a/OFFLINE_SYNC_PWA.md +++ b/OFFLINE_SYNC_PWA.md @@ -62,12 +62,12 @@ A critical feature is the ability to link tasting notes to a bottle that hasn't ## 📱 PWA Features -### Service Worker (`public/sw.js`) - "Ironclad" Strategy -The Service Worker implements an aggressive offline reliability strategy: +### Service Worker (`public/sw.js`) - "Paranoid Mode" Strategy +The Service Worker implements an extremely resilient "Cache-First, Network-Background" strategy for navigation: - **Pre-Caching**: The landing page (`/`), core static assets, and the sessions overview (`/sessions`) are cached during installation. -- **Fail-Fast Navigation**: Navigation requests have a 3-second timeout to prevent UI hangs during network transitions. -- **Root App Shell Fallback**: If a URL is not found in the cache while offline, the SW serves the Root (`/`). This allows Next.js to bootstrap and handle the routing client-side (including Scan and Note features embedded on the homepage) using local Dexie data. +- **SWR Navigation**: Navigation requests are handled with Stale-While-Revalidate. The SW serves the cached version immediately (instant load) and refreshes the cache in the background. +- **Universal Root Fallback**: If a URL is not found in the cache while offline, the SW serves the Root (`/`). This allows Next.js to bootstrap and handle the routing client-side (including Scan and Note features) using local Dexie data. - **RSC Data Resiliency**: Requests to `/_next/data/` return an empty JSON object if they fail, preventing "Application Error" screens. - **Stale-While-Revalidate**: Applied to static assets to ensure immediate UI response.