service worker
A script the browser runs in the background, separate from pages, that can intercept a site's network requests and act as a programmable proxy.
In more detail
Through its fetch event it can answer requests from a cache, the network or both, which enables offline support. It also receives push and sync events even when no page is open. Service workers only run on secure HTTPS origins.
Related terms
- service worker lifecycle — The states a service worker passes through: installing, installed and waiting, activating, activated, and finally redundant when replaced or failed.
- Cache Storage API — A browser storage API that saves pairs of Request and Response objects in named caches, usually managed by a service worker.
- fetch event — The event a service worker receives for every request its pages make, which it can answer with event.respondWith().
- network proxy — A program that sits between a client and the network, receiving requests and deciding how to answer or forward them.
Taught in
- Service Worker Lifecycle: Installation, Activation And Update — Frontend Architecture & Web Platform
- Cache Storage API: Offline Strategies And Cache-First Patterns — Frontend Architecture & Web Platform
- Background Sync, Push Notifications And PWA Manifests — Frontend Architecture & Web Platform