fix: Clear 2.1.0 frontend PWA cache (#6933)

Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
This commit is contained in:
CopilotandLouis Lam authored and GitHub committed 2026-02-18 13:16:49 +08:00
1 parent 6a9f800f58
commit 239ff865bf
2 files changed
+20 -1

No files matched your search

+17
View File
@@ -1,3 +1,20 @@
self.addEventListener("install", function (event) {
self.skipWaiting();
});
// Clear old caches from vite-plugin-pwa
self.addEventListener("activate", function (event) {
event.waitUntil(
(async function () {
const cacheNames = await caches.keys();
for (const cacheName of cacheNames) {
await caches.delete(cacheName);
}
await self.clients.claim();
})()
);
});
// Receive push notifications
self.addEventListener("push", function (event) {
if (self.Notification?.permission !== "granted") {