Skip to catalogue

255

service worker

also service worker update

A worker that can answer fetches. A bad cache serves yesterday’s app to today’s user.

What is service worker?

A service worker sits between the page and the network. It can cache GET responses. It cannot touch the DOM. A new worker installs, waits, then activates. skipWaiting plus clients.claim without a versioned cache mixes old HTML with new scripts. Authenticated API responses do not belong in a shared cache.

Why does service worker matter when vibe coding?

The draft registers a worker that caches everything, including POST and the API. Users stay on a broken bundle after you shipped a fix. Logout does not clear the cached account response.

How do you do service worker?

Cache the app shell with a version in the cache name. Network-first for API calls, or do not cache them. Delete old caches on activate. Do not cache responses that depend on a cookie.

How do you ask a model for service worker?

Add a service worker that caches the app shell under a versioned name. Do not cache authenticated API responses. Delete old caches on activate. Do not call skipWaiting unless the new shell can run with the new scripts.

What goes wrong with service worker?

A worker that never updates because the script URL is cached by HTTP with a year-long max-age.

adjacent