Spaces:
Runtime error
Runtime error
File size: 619 Bytes
2671e04 adb34c2 2671e04 adb34c2 2671e04 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | export async function registerServiceWorker() {
if (!("serviceWorker" in navigator)) {
return;
}
try {
const registrations = await navigator.serviceWorker.getRegistrations();
await Promise.all(registrations.map((registration) => registration.unregister()));
if ("caches" in window) {
const cacheNames = await window.caches.keys();
await Promise.all(
cacheNames
.filter((name) => name.startsWith("oapix-static"))
.map((name) => window.caches.delete(name))
);
}
} catch (error) {
console.error("service worker cleanup failed", error);
}
}
|