ArticleslgStudy

science

Content negotiation

Content negotiation is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Content negotiation rather than just read about it. In short: In computing, content negotiation refers to mechanisms defined as a part of HTTP that make it possible to serve different versions of a document (or more generally, representations of a resource) at the same URI, so that user agents can specify which version fits their capabilities the best. One classical use of this mechanism is to serve an image in GIF or PNG format, so that a browser that cannot display PNG image…

Content negotiation — main illustration
Content negotiation — illustration

Key takeaways

  • Content negotiation belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Content negotiation to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Content negotiation from memory before moving on to harder problems.

Reference excerpt

In computing, content negotiation refers to mechanisms defined as a part of HTTP that make it possible to serve different versions of a document (or more generally, representations of a resource) at the same URI, so that user agents can specify which version fits their capabilities the best. One classical use of this mechanism is to serve an image in GIF or PNG format, so that a browser that cannot display PNG images (e.g. MS Internet Explorer 4) will be served the GIF version. A resource may be available in several different representations; for example, it might be available in different languages or different media types. One way of selecting the most appropriate choice is to give the user an index page and let them select the most appropriate choice; however it is often possible to automate the choice based on some selection criteria.

Mechanisms HTTP provides for several different content negotiation mechanisms including: server-driven (or proactive), agent-driven (or reactive), transparent, and/or hybrid combinations thereof.

Server-driven Server-driven or proactive content negotiation is performed by algorithms on the server which choose among the possible variant representations. This is commonly performed based on user agent-provided acceptance criteria. To summarize how this works, when a user agent submits a request to a server, the user agent informs the server what media types or other aspects of content presentation it understands with ratings of how well it understands them. More precisely, the user agent provides HTTP headers that lists acceptable aspects of the resource and quality factors for them. The server is then able to supply the version of the resource that best fits the user agent's needs. For example, a browser could indicate that it would like information in German by setting the Accept-Language like this: Accept-Language: de The browser may instead say that German is preferred, if possible, but that English is also acceptable by setting: Accept-Language: de; q=1.0, en; q=0.5 Where the 'q' - quality - factor for German is higher than that for English. Multiple HTTP headers are often supplied together for content format or, specifically media type, language and a few other aspects of a resource. In addition to the commonly used Accept header for Media Type, the Accept-Language header for language negotiation, RFC 7231 also describes Accept-Charset & Accept-Encodings for character encodings and content codings (compression) respectively. An example of a more complex request is where a browser sends headers about language indicating German is preferred but that English is acceptable, as above, and that, regarding formats, HTML (text/html) is preferred over other text types (text/*), GIF (image/gif) or JPEG (image/jpg) images are preferred over other image formats (image/*) but that any other media type (*/*) is accepted as a last resort:

In addition to aspects of server-driven content negotiation by content type and by language specified in RFC 7231, there are extensions defining other aspects of content negotiation, such as Memento which describes use of a Accept-Datetime header to retrieve version of a resource's representation at particular points in time and the IETF/W3C's Content Negotiation by Profile which describes use of an Accept-Profile header to retrieve resource representations conforming to data profiles. Neither RFC 7231 nor the more recent related specifications such as Content Negotiation by Profile specify how to resolve trade-offs in cases where different headers specify conflicting requirements, such as, in the above example, choosing between an HTML page in English and a GIF image in German.

Agent-driven

Agent-driven or reactive content negotiation is performed by algorithms in the user-agent which choose among the possible variant representations. This is commonly performed based on a server provided list of representations and metadata about them. To summarize how this works, when a user agent submits a request to a server, the server informs the user-agent which representations it has available as well as any metadata it has about each representation (e.g., content-type, quality, language, etc.). The user-agent then resubmits the request to a specific URL for the chosen representation. This can be automatically chosen by the user-agent or the user-agent can present the user with the choices and the user can directly choose such. More precisely, the server responds with either 300 Multiple Choices or 406 Not Acceptable (when server-driven, user-agent acceptance criteria are provided but the server cannot automatically make a selection). Unfortunately HTTP leaves the format of the list of representations and metadata along with selection mechanisms unspecified.

References

This article is based in part on this page Archived 2014-11-15 at the Wayback Machine, which is copyrighted by the Apache Foundation but released under a free license.

External links RFC 7231 — Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content – (Section 5.3: Content Negotiation) RFC 2295 — Transparent Content Negotiation in HTTP RFC 2296 — HTTP Remote Variant Selection Algorithm -- RVSA/1.0 Apache Content Negotiation Open source PHP content negotiation library (supports wildcards and q values) Discussion about XHTML serving with content negotiation and browser concerns requiring this

Illustrations

Content negotiation illustration

Worked examples

Example 1 — a first encounter with Content negotiation

Start with the simplest possible case. Write down what Content negotiation claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Content negotiation before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Content negotiation ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Content negotiation

In research
Content negotiation appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Content negotiation in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Content negotiation is common in secondary-school and first-year university syllabi. It links to neighbouring topics Hypertext Transfer Protocol, so understanding it makes those chapters shorter.
In everyday life
Look for Content negotiation outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Content negotiation” →

How to study Content negotiation in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Content negotiation means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Content negotiation out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Content negotiation in simple terms?

In computing, content negotiation refers to mechanisms defined as a part of HTTP that make it possible to serve different versions of a document (or more generally, representations of a resource) at the same URI, so that user agents can specify which version fits their capabilities the best. One cl…

Why does Content negotiation matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Content negotiation?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Content negotiation.

Tags

  • Hypertext Transfer Protocol

Keep exploring