docs: correct routes in offline sync documentation

fix: remove non-existent routes from sw.js pre-caching
This commit is contained in:
2025-12-20 23:10:18 +01:00
parent c9e3caff5a
commit ceb964a07d
2 changed files with 11 additions and 11 deletions

View File

@@ -62,13 +62,14 @@ A critical feature is the ability to link tasting notes to a bottle that hasn't
## 📱 PWA Features ## 📱 PWA Features
### Service Worker (`public/sw.js`) ### Service Worker (`public/sw.js`) - "Ironclad" Strategy
- **Strategy**: Network-First. Attempts to fetch from network, falls back to cache if offline. The Service Worker implements an aggressive offline reliability strategy:
- **Cache Bypassing**: Explicitly bypasses cache for:
- `*/auth/*` - **Pre-Caching**: The landing page (`/`) and core static assets are cached during installation.
- `*/api/*` - **Fail-Fast Navigation**: Navigation requests have a 3-second timeout to prevent UI hangs during network transitions.
- `*.supabase.co/*` - **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 using local Dexie data.
- **Asset Caching**: Caches static assets (`manifest.json`, icons) during installation. - **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.
### Manifest (`src/app/manifest.ts`) ### Manifest (`src/app/manifest.ts`)
Defines the app's appearance when installed: Defines the app's appearance when installed:
@@ -83,9 +84,10 @@ Defines the app's appearance when installed:
- `src/lib/db.ts`: Database definition and TypeScript interfaces. - `src/lib/db.ts`: Database definition and TypeScript interfaces.
- `src/hooks/useBottleData.ts`: Example of the SWR pattern implementation. - `src/hooks/useBottleData.ts`: Example of the SWR pattern implementation.
- `src/components/UploadQueue.tsx`: The "Sync Engine" UI and logic coordinator. - `src/components/UploadQueue.tsx`: The "Sync Engine" UI and logic coordinator.
- `src/components/CameraCapture.tsx`: Integrated scanning feature.
- `src/components/TastingNoteForm.tsx`: Integrated tasting note feature.
- `src/components/PWARegistration.tsx`: Client-side Service Worker registration handler. - `src/components/PWARegistration.tsx`: Client-side Service Worker registration handler.
## ⚠️ Edge Case Handling ## ⚠️ Edge Case Handling
- **Partial Sync**: If a scan succeeds but a tasting fails, the tasting remains in the queue with the now-valid `bottle_id`. - **Partial Sync**: If a scan succeeds but a tasting fails, the tasting remains in the queue with the now-valid `bottle_id`.
- **Duplicate Scans**: The system relies on the user not submitting the same scan multiple times while offline (UI prevents multiple clicks).
- **Stale Cache**: Caches are overwritten on every successful online fetch to ensure eventual consistency. - **Stale Cache**: Caches are overwritten on every successful online fetch to ensure eventual consistency.

View File

@@ -2,9 +2,7 @@ const CACHE_NAME = 'whisky-vault-v4'; // Increment version for "Ironclad" strate
// CONFIG: Core pages and assets to pre-cache immediately on install // CONFIG: Core pages and assets to pre-cache immediately on install
const CORE_PAGES = [ const CORE_PAGES = [
'/', // Dashboard / Home '/', // Dashboard / Home (Includes Scan and Tasting features)
'/tasting/new', // Critical: Add Tasting Screen
'/scan', // Critical: Scan Screen
]; ];
const STATIC_ASSETS = [ const STATIC_ASSETS = [