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
This commit is contained in:
@@ -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));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user