Request and Response objects
The objects the Fetch API uses to represent an HTTP request and its response, including URL, method, headers and body.
In more detail
A service worker receives a Request in its fetch event and must answer with a Response, from the network, a cache or built by hand. A body can only be read once, so clone the response before both caching and returning it.
Related terms
- Fetch API — The standard JavaScript function fetch() for making HTTP requests, built into browsers and current server runtimes, which returns a promise for the response.
- Cache Storage API — A browser storage API that saves pairs of Request and Response objects in named caches, usually managed by a service worker.
- ReadableStream — A browser object that delivers data in chunks as it arrives, such as a fetch response.body, instead of all at once at the end.
Taught in
- Cache Storage API: Offline Strategies And Cache-First Patterns — Frontend Architecture & Web Platform
- The Fetch API: Streaming Responses, HTTP Caching And Keepalive — Frontend Architecture & Web Platform