diff --git a/public/sw.js b/public/sw.js index a487324..b047ac1 100644 --- a/public/sw.js +++ b/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;