A service worker is a special script which runs in the background in the browser and manages network requests to a given origin. It's originally installed by an app and stays resident on the user's machine/device. It's activated by the browser when a page from its origin is loaded, and has the option to respond to HTTP requests during the page loading, including the initial navigation request (for /index.html
). This makes service workers very useful for true offline support in applications.
Additionally, service workers are the client-side endpoint for push notifications on the web.