Service Worker Lifecycle - Interactive Lab | IconVault
Visualize the service worker lifecycle: install, activate and fetch events with a live event log. Free, in-browser.
Service Worker Lifecycle
Animated install, activate and fetch flow
This page simulates the lifecycle, it does not register a real worker. A real service worker needs HTTPS (or localhost) and must live in its own file, like /sw.js, registered with navigator.serviceWorker.register("/sw.js").
Lifecycle stages
Installing
install event: precaching the app shell
Installed / waiting
waiting: old worker still controls the page
Activating
activate event: cleaning old caches
Activated
clients.claim(): this worker now controls pages
5 of 5 free simulations left.
Event log
Run a simulation. install, activate and fetch events appear here exactly as a real worker would log them.
Copy-ready sw.js template
// sw.js - cache-first service worker template
const CACHE = "app-v1";
const SHELL = ["/", "/styles.css", "/app.js", "/logo.png"];
self.addEventListener("install", (event) => {
event.waitUntil(
caches.open(CACHE).then((cache) => cache.addAll(SHELL)).then(() => {
// take over immediately instead of waiting
return self.skipWaiting();
}),
);
});
self.addEventListener("activate", (event) => {
event.waitUntil(
caches.keys().then((names) =>
Promise.all(names.filter((n) => n !== CACHE).map((n) => caches.delete(n))),
).then(() => self.clients.claim()),
);
});
self.addEventListener("fetch", (event) => {
// cache-first: fast repeat visits, network as backup
event.respondWith(
caches.match(event.request).then(
(hit) => hit ?? fetch(event.request),
),
);
});
About this tool
IconVault's Service Worker Lifecycle playground animates the stages every worker goes through: installing (precaching the app shell), installed / waiting, activating (cleaning old caches), and activated (controlling pages). Each simulation writes a realistic event log, showing `install`, `activate` and `fetch` events exactly as a real worker would fire them.
This page is a simulation and is honest about it: a real service worker needs HTTPS (or localhost) and must live in its own file. That is why the lab also ships a copy-ready cache-first `sw.js` template you can download and register with `navigator.serviceWorker.register`. Free, runs fully in your browser, no signup.
Frequently asked questions
Popular searches
More tools
Algorithm Visualizer
Watch sorting and searching animate step by step
Alt Text Helper
Write better image alt text with live feedback
ARIA Reference
Searchable ARIA roles and attributes guide
Array Visualizer
Step through map, filter, reduce like a debugger
Coming soon
CLI
Coming soon
Figma plugin
Coming soon
VS Code extension
Coming soon
Chrome extension
Coming soon
AI icon generator
Coming soon
Team workspaces
Coming soon