Intercept Network Requests with the `fetch` Event

The `fetch` event turns your Service Worker into a programmable network proxy. Use it to intercept outgoing requests to serve assets from a cache for offline support or to synthesize custom responses.
The `fetch` event turns your Service Worker into a programmable network proxy, letting you intercept any outgoing request from your app. It's the key to offline-first apps, where you serve responses from a local cache instead of the network. You can also implement custom routing or create synthetic API responses. The main footgun: you must call `event.respondWith()` synchronously, passing it a `Promise` that resolves to a `Response`. Calling it inside a `.then()` block won't work.
Read the original → developer.mozilla.org
- #service worker
- #web apis
- #networking
- #pwa
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.