Skip to content
Painter
Guides

Service workers: the three lines worth having

Most service worker code is a caching library nobody asked for. A small one is genuinely useful.

The ambitious version of a service worker intercepts everything, manages its own cache, and eventually serves somebody a three-week-old page. The small version caches the shell and gets out of the way.

Have an escape hatch before you register one

A broken service worker is sticky. Ship the unregister path first, on day one, before anything depends on it.

Cache the shell, network-first for HTML, cache-first for hashed assets. That is the whole useful surface for most sites.

Leave a comment

Real questions get real answers. The editorial team reads every thread.