fix: address final PWA review findings

This commit is contained in:
AgendaPro Dev
2026-07-27 17:19:45 -06:00
parent 43f5d1374c
commit 0b466f33f3
5 changed files with 89 additions and 11 deletions
+7 -3
View File
@@ -10,7 +10,11 @@ self.addEventListener("install", (event) => {
self.addEventListener("activate", (event) => {
event.waitUntil(
caches.keys()
.then((keys) => Promise.all(keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key))))
.then((keys) => Promise.all(
keys
.filter((key) => key.startsWith("agendamax-shell-") && key !== CACHE_NAME)
.map((key) => caches.delete(key))
))
.then(() => self.clients.claim())
);
});
@@ -24,7 +28,7 @@ self.addEventListener("fetch", (event) => {
event.respondWith(
fetch(request)
.then((response) => {
if (response.ok) {
if (request.credentials === "omit" && response.ok) {
const copy = response.clone();
void caches.open(CACHE_NAME).then((cache) => cache.put(request, copy));
}
@@ -36,7 +40,7 @@ self.addEventListener("fetch", (event) => {
}
const cacheableDestination = new Set(["script", "style", "image", "font", "manifest", "worker"]);
if (!cacheableDestination.has(request.destination)) return;
if (request.credentials !== "omit" || !cacheableDestination.has(request.destination)) return;
event.respondWith(
caches.match(request).then((cached) => {