shellphone.app/app/service-worker/activate.ts
m5r 1e9b7a8aa2 * fix "dev:build" watch mode
* remove cross-env
* append build hash to service worker cache names for easy purge
2022-06-11 15:13:28 +02:00

15 lines
435 B
TypeScript

import { deleteCaches } from "./cache-utils";
declare const self: ServiceWorkerGlobalScope;
export default async function handleActivate(event: ExtendableEvent) {
console.debug("Service worker activated");
// @ts-ignore
if (self.registration.navigationPreload) {
// @ts-ignore
await self.registration.navigationPreload.enable();
}
await deleteCaches(); // TODO: maybe wait for the user to reload before busting the cache
}