What is Service Worker?
A background script that intercepts network requests, enabling offline support, caching strategies, and push notifications.
Definition
A service worker is a JavaScript worker the browser runs on a separate thread, registered per origin, that sits as a programmable proxy between a page and the network. Its fetch event handler implements caching strategies—cache-first for static assets, network-first or stale-while-revalidate for API data—using the Cache Storage API, which is what makes PWAs installable and offline-capable. It also receives push messages and background sync events with no page open. Service workers require HTTPS, have no DOM access, and follow a deliberate install/activate lifecycle; Workbox abstracts the boilerplate and precaching manifest generation.

