Fix: bump SW cache to v12, switch JS/CSS to network-first
Old pedscribe-v11 cache was serving stale admin.js to browsers even after server updates. New cache name forces old SW to deactivate and all clients to get fresh JS on next load. Also switch JS/CSS from stale-while-revalidate to network-first so code fixes are picked up immediately.
This commit is contained in:
parent
0ca4ba1c04
commit
53a486dbd5
1 changed files with 8 additions and 9 deletions
17
public/sw.js
17
public/sw.js
|
|
@ -4,7 +4,7 @@
|
|||
// API calls always fresh (critical for medical data accuracy)
|
||||
// ============================================================
|
||||
|
||||
var CACHE_NAME = 'pedscribe-v11';
|
||||
var CACHE_NAME = 'pedscribe-v12';
|
||||
var SHELL_ASSETS = [
|
||||
'/',
|
||||
'/index.html',
|
||||
|
|
@ -66,16 +66,15 @@ self.addEventListener('fetch', function(event) {
|
|||
return;
|
||||
}
|
||||
|
||||
// Static assets (JS, CSS, icons) — stale-while-revalidate
|
||||
// Static assets (JS, CSS, icons) — network-first so code updates apply immediately
|
||||
if (url.pathname.match(/\.(js|css|png|ico|woff2?)$/)) {
|
||||
event.respondWith(
|
||||
caches.match(event.request).then(function(cached) {
|
||||
var fetchPromise = fetch(event.request).then(function(response) {
|
||||
var clone = response.clone();
|
||||
caches.open(CACHE_NAME).then(function(cache) { cache.put(event.request, clone); });
|
||||
return response;
|
||||
}).catch(function() { return cached; });
|
||||
return cached || fetchPromise;
|
||||
fetch(event.request).then(function(response) {
|
||||
var clone = response.clone();
|
||||
caches.open(CACHE_NAME).then(function(cache) { cache.put(event.request, clone); });
|
||||
return response;
|
||||
}).catch(function() {
|
||||
return caches.match(event.request);
|
||||
})
|
||||
);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue