Service Worker Lifecycle - Interactive Lab | IconVault

Visualize the service worker lifecycle: install, activate and fetch events with a live event log. Free, in-browser.

All tools

Service Worker Lifecycle

Animated install, activate and fetch flow

5 of 5 free uses left

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

1

Installing

install event: precaching the app shell

2

Installed / waiting

waiting: old worker still controls the page

3

Activating

activate event: cleaning old caches

4

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

service worker lifecycleservice worker tutorialservice worker installservice worker activateservice worker fetch eventservice worker explainedhow service workers workservice worker stagesinstalling installed activating activatedskipwaitingwhat is skipwaitingclients.claimclients claim service workerservice worker waitingservice worker updatehow to update service workerservice worker cache firstcache first strategystale while revalidatenetwork first strategyservice worker caching strategiesprecache app shellcaches apicache storageservice worker event logservice worker visualizerlearn service workersservice worker playgroundservice worker demopwa service workerpwa offlineoffline firstservice worker https requirementservice worker localhostregister service workernavigator.serviceworker.registersw.js templateservice worker templateservice worker example codeservice worker fetch handlerservice worker activate eventservice worker install eventdelete old caches service workerservice worker versioningservice worker not updatingservice worker stuck waitingfree service worker toolservice worker lifecycle diagramservice worker cheat sheetpwa tutorialworkbox vs service worker

More tools

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

View all 10+ tools →