self.addEventListener("activate", (event) => {
const cacheAllowlist = ["v2"];
event.waitUntil(
caches.keys().then((cacheNames) =>
Promise.all(
cacheNames.map((cacheName) => {
if (!cacheAllowlist.includes(cacheName)) {
return caches.delete(cacheName);
}
return undefined;
}),
),
),
);
});ServiceWorkerGlobalScope: activate event / notebook
ServiceWorkerGlobalScope: activate event
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
self.onactivate = (event) => {
// …
};