From 30abecc07df2b05cc98e7750a492b575d65c5a76 Mon Sep 17 00:00:00 2001 From: consultoria-as Date: Thu, 14 May 2026 22:26:27 +0000 Subject: [PATCH] fix(sw): v6 with network-first HTML strategy - Bump cache to nexus-pos-v6 to force invalidation - HTML pages now use network-first instead of cache-first This ensures users always get the latest HTML with correct JS/CSS references (?v=3) instead of stale cached HTML - Remove HTML pages from APP_SHELL precache (only static assets) - Keep cache-first for JS/CSS/images --- pos/static/pwa/sw.js | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/pos/static/pwa/sw.js b/pos/static/pwa/sw.js index 94fd3ab..15917cb 100644 --- a/pos/static/pwa/sw.js +++ b/pos/static/pwa/sw.js @@ -1,20 +1,10 @@ // /home/Autopartes/pos/static/pwa/sw.js -// Nexus POS — Service Worker v5 +// Nexus POS — Service Worker v6 // Self-contained vanilla JS. No external imports. -const CACHE_NAME = 'nexus-pos-v5'; +const CACHE_NAME = 'nexus-pos-v6'; const APP_SHELL = [ - '/pos/login', - '/pos/sale', - '/pos/catalog', - '/pos/inventory', - '/pos/customers', - '/pos/invoicing', - '/pos/accounting', - '/pos/dashboard', - '/pos/config', - '/pos/reports', '/pos/static/css/tokens.css', '/pos/static/css/common.css', '/pos/static/js/app-init.js', @@ -132,8 +122,8 @@ self.addEventListener('fetch', function (event) { return; } - // Don't cache login page - if (url.pathname === '/pos/login' || url.pathname === '/pos/login/') { + // HTML pages -> network-first (always fresh) + if (req.headers.get('accept') && req.headers.get('accept').indexOf('text/html') !== -1) { event.respondWith(networkFirst(req)); return; } @@ -181,7 +171,7 @@ self.addEventListener('fetch', function (event) { return; } - // Everything else -> cache-first + // Everything else (JS, CSS, images) -> cache-first event.respondWith(cacheFirst(req)); });