🎁 New User? Get 20% off your first purchase with code NEWUSER20 Register Now →
Menu

Categories

Web Development Intermediate

What is Content Negotiation?

An HTTP mechanism where client and server agree on the best representation of a resource based on format, language, or encoding preferences.

Content negotiation allows serving different representations of the same resource based on client capabilities and preferences. The Accept header specifies preferred media types (application/json, text/html). Accept-Language indicates language preference (en, de, fr). Accept-Encoding specifies compression support (gzip, br). The server examines these headers and responds with the best match, indicating the choice via Content-Type, Content-Language, and Content-Encoding response headers. This enables APIs to return JSON or XML from the same endpoint, serve WebP images to supporting browsers with JPEG fallback, and deliver localized content — all at the same URL.

Related Terms

MVC (Model-View-Controller)
An architectural pattern that separates an application into three components: data (Model), interface (View), and logic (Controller).
Caching
Storing copies of frequently accessed data in faster storage to reduce load times and server processing.
JSON Schema
A vocabulary for validating the structure and content of JSON data, ensuring API requests and responses conform to expected formats.
CORS Headers
HTTP headers that control cross-origin resource sharing between different domains, specifying allowed origins, methods, and headers.
OAuth Scope
A mechanism in OAuth that limits an application's access to a user's account to specific resources or actions.
PHP
A widely-used server-side scripting language designed for web development that powers over 75% of websites including WordPress.
View All Web Development Terms →