Home >>HTTP Tutorial >HTTP Content Negotiation

HTTP Content Negotiation

HTTP Content Negotiation

Most of HTTP's responses involve an entity that contains the user-interpretation information. Of necessity, it is used to provide the user with the best entity available that corresponds to the request. Unfortunately, not all users have the same expectations for what is best for cache and server. Therefore HTTP has provisions for many "content negotiation" processes. The process of selecting the best representation for a given answer when there are multiple representations available.

Any response that includes an entity-body Can also be subject to negotiation, including responses to errors.

There are two kinds of content negotiation in HTTP, server-led negotiation, and agent-driven negotiation. Both the negotiations are orthogonal and can thus be used either in combination or individually.

One type of combination called transparent negotiation that occurs when the origin server provides the agent-driven negotiation information that the cache uses to provide server-driven negotiation for subsequent requests.

Server-driven Negotiation

When a server-driven negotiation occurs, then an algorithm located at the server selects the best representation for an answer. The collection and the contents are based on the available representation of a resource. Selection is often based on the contents of relevant header fields in the request message or on other information pretending to be applicable.

Advantages

  1. It is useful when the user agent has trouble in defining the algorithm for selecting from among the available representations.
  2. It is useful when the server decides to give the client its "best guess" along with the initial response.
  3. To improve the server's guess, the user agent can include fields of request headers which define their preferences for such a response.

Disadvantages

  1. It is impossible for the server to decide exactly what would be best for any given user. That's why the server will need to be fully aware of both the user agent's capabilities and the intended usage for the answer.
  2. It complicates the implementation of an origin server and the algorithms to produce responses to a request.

Agent-driven Negotiation

When an agent-driven negotiation takes place, after receiving an initial response from the origin server, the user agent performs selection of the best representation for an answer. In agent-driven negotiation, the selection is based on a list of available response representations, which is included within the initial response header fields or entity-body, each representation being defined by its own URI. Selection from a list of representations can be done either manually or automatically by selecting the user from a created menu.

Advantages

  1. It is used when the response differs across widely used dimensions when the server of origin can not assess a user agent's ability to analyse the request.
  2. It is used when spreading server load in public caches and reducing network use.

Disadvantages

A negotiation led by an agent suffers when a second request is required to get the best alternative representation.

Transparent Negotiation

It is a mixture of server-led negotiation and agent-driven negotiation. If a cache is given in the form of a list of available response representations, and the cache fully understands the dimension of the variance, then the cache becomes capable of conducting server-driven negotiation on behalf of the origin server.