Protocols
Saved & recent

Content negotiation

Also called: representation negotiation, Accept, Vary

Content negotiation chooses a representation of a resource using information such as acceptable media types, languages or content encodings. In server-driven negotiation, request fields such as Accept or Accept-Language provide preferences; the server chooses among the representations it can supply.

A hypothetical report endpoint might return JSON to one client and HTML to another at the same URL. The response’s Content-Type identifies the chosen form. When selection depends on a request field, Vary tells caches to account for it. Preferences do not guarantee that every requested format is available.

Read first
HTTP headers
Related
HTTP headers, HTTP caching, REST
Further reading
/report shared cache boundary Accept: application/json Accept: text/html JSON representation {"total":12} HTML representation <p>Total: 12</p> Vary: Accept selection field
Two representations of the same hypothetical report. Accept guides selection; Vary: Accept tells a cache to account for that request field when matching stored responses.

View in the full Protocols collection