Vary header
The response header that lists which request headers changed the answer, so caches keep separate copies for each value.
In more detail
Without it, a cache could store the JSON answer for one caller and serve it to another who asked for something else. Caches then store one copy per value of each listed header, such as one per Accept or one per Origin.
Example
In the APIs course: The course service sends Vary: Accept on negotiated answers and Vary: Origin on CORS preflights, and a partial response must vary on the field choice.Related terms
- content negotiation — The way a client and server agree on the format, language or compression of a response using request headers such as Accept.
- HTTP cache — A store that keeps HTTP responses and reuses them for later requests, following the rules the server sends in Cache-Control.
- CORS — The browser rule set that decides whether web page code from one origin may read a response from a different origin.
- partial response — A response that contains only the fields the client asked for, such as ?fields=id,title, which is a smaller representation of the same resource.
Taught in
- Headers And Content Negotiation — Modern API Architecture: REST, GraphQL & gRPC
- Cookies And CORS — Modern API Architecture: REST, GraphQL & gRPC
- Partial Responses — Modern API Architecture: REST, GraphQL & gRPC