Skip to main content
短.be

Content Negotiation

A mechanism in which the client and server negotiate the optimal content format (language, media type, encoding) through HTTP headers.

Dec 5, 2025 · About 1 min read

Redirect

Content negotiation is the HTTP mechanism by which a client (browser) and server agree on the best representation of a requested resource. The same URL can return different content depending on the user's language preference, device capabilities, or supported formats.

Negotiation happens primarily through HTTP request headers. The Accept header specifies supported media types (text/html, application/json, etc.), Accept-Language specifies preferred languages (ja, en-US, etc.), and Accept-Encoding specifies supported compression methods (gzip, br, etc.).

Content negotiation intersects with shortened URLs in multilingual sites. A single short link can redirect to a Japanese or English page based on the browser's language setting. However, from an SEO standpoint, having distinct URLs per language with hreflang tags is preferred, because content negotiation can prevent search engines from correctly indexing each language version.

In API design, content negotiation is equally important. A URL shortening API that returns JSON or XML depending on the Accept header is a common pattern. RESTful design principles encourage serving multiple representations of the same resource.

Two types of content negotiation exist: server-driven (the server inspects request headers and decides) and agent-driven (the server presents options and the client chooses). Server-driven negotiation is overwhelmingly more common on the web. You can find related books on Amazon.

Share on XHatena

Was this article helpful?

Related Terms

Related Articles

FAQ

Should I use content negotiation to switch languages automatically?
It improves user experience, but be cautious about SEO. Search engines may not index each language version correctly. Using separate URLs per language with hreflang tags is the recommended approach.
How do I implement content negotiation in an API?
Parse the Accept header of the request. Return JSON for application/json and XML for application/xml. If the requested format is not supported, respond with HTTP 406 (Not Acceptable).
How is the Accept-Language header set?
It is sent automatically based on the browser's language settings. For example, a browser configured for Japanese sends something like "Accept-Language: ja,en-US;q=0.9,en;q=0.8," listing languages with priority weights.

Ready to create a short URL?

Shorten a URL for Free