Rendering and architecture · API

Service worker

A script that the browser runs in the background for a website, sitting between the page and the network so it can serve cached files offline and receive push messages.

App shapes · updated

How it works

A page registers a service worker file, which the browser installs and keeps separately from any open tab. It can intercept every network request from the site and decide whether to answer from the Cache Storage API, go to the network, or both, which is how offline pages and instant repeat visits work. It also receives push notifications and background sync events while the site is closed.

Service workers run only over HTTPS (or on localhost) and cannot touch the page's DOM. Caching strategies are easy to get wrong, and a faulty worker can keep serving stale files for a long time, so most teams use Workbox or a framework plugin. Browser extensions built on Manifest V3 also use a service worker as their background script.

More in Rendering and architecture

App shapes

All 16 Rendering and architecture terms

Crafted in the dark. Shipped to the world.

Tell us what you are building. You get a private project space with a proposal and a line-by-line quote within a day.