fix: service worker cache busting — unregister old sw on load, bump cache version, stop caching HTML
- Bump sw.js cache from v2 to v3 - Unregister all old service workers on page load - Stop caching HTML/navigation (caused stale CSS refs after rebuild)
This commit is contained in:
1 parent
b37b6bc2b9
commit
c432d4e95d
7 files changed
+37
-38
No files matched your search
+3
-11
@@ -1,5 +1,5 @@
|
||||
const CACHE = "atom-v2";
|
||||
const API_CACHE = "atom-api-v2";
|
||||
const CACHE = "atom-v3";
|
||||
const API_CACHE = "atom-api-v3";
|
||||
|
||||
self.addEventListener("install", () => self.skipWaiting());
|
||||
|
||||
@@ -60,14 +60,6 @@ self.addEventListener("fetch", (event) => {
|
||||
}
|
||||
|
||||
if (req.mode === "navigate") {
|
||||
event.respondWith(
|
||||
fetch(req)
|
||||
.then((res) => {
|
||||
const copy = res.clone();
|
||||
caches.open(CACHE).then((c) => c.put(req, copy)).catch(() => {});
|
||||
return res;
|
||||
})
|
||||
.catch(() => caches.match(req).then((hit) => hit || caches.match("/"))),
|
||||
);
|
||||
event.respondWith(fetch(req));
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user