Content negotiation is the mechanism by which a server picks the most appropriate representation of a resource for a single URL based on the client's preferences and capabilities.
Language, media type, encoding (compression), and charset can all be negotiated, serving one resource in various forms.
The most common form is server-driven negotiation: the client signals preferences via headers like `Accept` (desired MIME type), `Accept-Language`, and `Accept-Encoding` (gzip/br), ranking each with a quality value `q`. E.g. `Accept: application/json, text/html;q=0.9`. The server considers these, returns JSON or HTML, and declares its choice via `Content-Type`, `Content-Language`, and `Content-Encoding`.
Its interaction with caching matters: since the same URL yields different responses by header, the server must use the `Vary` header to name which request headers affect the response (e.g. `Vary: Accept-Encoding`). Omitting it causes cache poisoning, like a CDN serving a compressed response to a client that can't decompress it. `300 Multiple Choices` exists for negotiation but is rare in practice, and explicitly distinguishing language/format in the URL path (`/en/`, `.json`) is often used alongside.