Service Worker

A Service Worker is a type of Web Worker that can act like a proxy server between a web app and the network.

It can intercept all outgoing requests and incoming responses of a web app and enables it to work offline.

Typically, a Service Worker caches all assets of a web app locally when it is activated and then serves these assets from the cache, reducing network traffic or eliminating it altogether.

This literally means you can intercept any request and serve basically whatever you want. You can serve static assets straight from the local cache or even serve API responses and BLOBs from IndexedDB.

Service Workers are supported by all modern browsers and work by progressive enhancement, which means that nothing will break when a user visits your website with an old browser that doesn't support Service Workers. It just won't work offline in that case.