From c56961d7d95d15df93c56006ad2ea8f7ffd38f9f Mon Sep 17 00:00:00 2001 From: Dave Date: Mon, 31 Aug 2026 01:48:49 +0200 Subject: [PATCH] chore(pos): bump SW cache to v13, skip /api/ caching, scope manifest to /pos/ Co-Authored-By: Claude --- public/pos/manifest.json | 4 ++-- public/pos/sw.js | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/public/pos/manifest.json b/public/pos/manifest.json index fdf4fa8..bb7c986 100644 --- a/public/pos/manifest.json +++ b/public/pos/manifest.json @@ -2,8 +2,8 @@ "name": "WFSALES POS", "short_name": "WFSALES POS", "description": "WFSALES POS — point of sale", - "start_url": "index.html", - "scope": ".", + "start_url": "/pos/index.html", + "scope": "/pos/", "display": "standalone", "orientation": "portrait", "background_color": "#ffffff", diff --git a/public/pos/sw.js b/public/pos/sw.js index c84cd26..9ad6851 100644 --- a/public/pos/sw.js +++ b/public/pos/sw.js @@ -1,5 +1,5 @@ // Service worker — cache app shell, network-first for HTML + theme.js, cache-first for other static. -const CACHE = "pos-v12"; +const CACHE = "pos-v13"; const APP_SHELL = [ './', './index.html', @@ -7,7 +7,7 @@ const APP_SHELL = [ './receipt.html', './history.html', './cashup.html', - './pb-config.js', + './pos-config.js', './pos-app.js', './theme.js', './manifest.json' @@ -28,8 +28,9 @@ self.addEventListener('activate', e => { self.addEventListener('fetch', e => { const url = new URL(e.request.url); - // Never cache PocketBase API - if(url.hostname.includes('pocketbase') || url.hostname.includes('sslip.io')) return; + // Never cache API responses — only the static app shell. Serving a + // stale /catalog or, worse, a cached /checkout would be actively wrong. + if(url.pathname.startsWith('/api/')) return; // HTML navigations: always network-first so the user gets the latest page if(e.request.mode === 'navigate'){ e.respondWith(