Other meanings of Service worker
WEB PLATFORM
A service worker is a browser-managed JavaScript worker that runs separately from a web page and can mediate network requests, cache resources, and support features such as offline access and push notifications. It operates within a defined origin and normally requires a secure context, such as HTTPS.
A service worker is a programmable network intermediary for web applications, positioned between a page, its resources, and the network.1 Unlike a traditional page script, it has no direct access to the document or user interface; instead, it communicates with pages through messages and responds to events such as installation, activation, and fetch. This separation lets a site continue selected operations when its pages are not currently open.
Service workers are a foundation of progressive web applications, but they are also useful in ordinary websites. A worker can provide an offline shell, accelerate repeat visits with the Cache API, coordinate background synchronization, or receive push messages. It is scoped to a path within an origin, so its authority is limited by both origin rules and its registration scope.
The lifecycle deliberately separates downloading, installation, waiting, and activation so that a new worker does not abruptly disrupt pages controlled by an older one.2 A page registers a script; the browser downloads it and fires install, where essential assets can be cached. After installation, the worker normally waits until existing controlled pages close, then receives activate and may remove obsolete caches. Calling skipWaiting() and using clients.claim() can shorten this transition, but may expose a page to mixed versions if used carelessly.
The fetch event allows application-defined strategies, including cache-first, network-first, stale-while-revalidate, and network-only behavior. The worker does not replace the browser's HTTP cache; its script-controlled cache is a separate, script-accessible layer.
Security boundaries shape what a service worker can do: registration is generally restricted to secure contexts, and the worker is constrained by the same-origin policy.3 A worker cannot freely inspect another origin's data, and browsers may terminate its process whenever it is idle. Developers must therefore treat each event as restartable, persist durable state in storage, and avoid relying on global variables between events.
Workers are powerful but not universal background programs. They cannot directly manipulate the DOM, display arbitrary user-interface elements, or guarantee that a task will run at a chosen time. Browser storage quotas, eviction policies, network failures, and opaque cross-origin responses can also affect caching. HTTPS protects delivery and registration, but it does not make cached application data automatically trustworthy; cache invalidation and update policies remain the application's responsibility.1
Service workers have several less visible roles beyond offline pages. They can intercept navigation requests, synthesize responses, respond to push events, and coordinate background synchronization when the browser later regains connectivity.4 Their event-driven design also means that a worker may be started solely for one event and then shut down, a behavior that distinguishes it from a continuously running server process.
A registration can have multiple clients, such as tabs and windows, and can enumerate or message those clients through the Clients interface. Update checks compare the registered script and its imported dependencies, while activation commonly includes deletion of versioned caches left by earlier releases. Developers sometimes use libraries such as Workbox to generate routing and precaching logic, but such tools still operate within the browser's lifecycle, quota, and security constraints. Push delivery also depends on a browser's push service and user permission; it is not a guaranteed substitute for a native background process.5
Scope: this entry describes the browser web-platform technology, not the occupational meaning of “service worker” or similarly named server software.
Help improve the encyclopedia. Reports go straight to the site manager.