From 6e5889590d9392a9a17fcf834a43d1a213a56275 Mon Sep 17 00:00:00 2001 From: AmirrezaRezaeii Date: Tue, 21 Apr 2026 15:32:01 +0330 Subject: [PATCH] Strategy: cache only --- public/sw.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/public/sw.js b/public/sw.js index 3472c37..ba11172 100644 --- a/public/sw.js +++ b/public/sw.js @@ -61,12 +61,18 @@ self.addEventListener("activate", function (event) { // Strategy: cache with network fallback +// self.addEventListener("fetch", (event) => { +// event.respondWith( +// caches.open(CACHE_STATIC_NAME).then((cache) => { +// return cache.match(event.request).then((res) => { +// return res || fetch(event.request); +// }); +// }), +// ); +// }); + +// Strategy: cache only + self.addEventListener("fetch", (event) => { - event.respondWith( - caches.open(CACHE_STATIC_NAME).then((cache) => { - return cache.match(event.request).then((res) => { - return res || fetch(event.request); - }); - }), - ); + event.respondWith(caches.match(event.request)); });