What’s Content Negotiation?

Print anything with Printful



Content negotiation in HTTP allows servers to host multiple file types and languages, with different levels of quality, for better content delivery. Two methods of negotiation are server-driven and agent-driven, with privacy concerns for the former and multiple requests for the latter.

Content negotiation is a technique described in the hyptertext transfer protocol (HTTP) specification that allows a remote client to make a more specific request to a web server. The method gives the server the ability to host multiple file types, documents in different languages, and more, each with different levels of quality. These separate selections are hosted as a single reference, denoted by their uniform resource identifier (URI), and are intended to provide more applicable content when it is available on the server.

Where a URL (Uniform Resource Locator) is a reference to a file in a specific location, such as within a folder on the server, a URI can refer to anything, virtually anywhere. URI specifications, such as the location of the file to be delivered, the file name and its type, are processed after the content has been negotiated. This allows for the various pieces of content to be in different locations, such as all the files for a particular language being organized in that language’s folder on the server.

The idea behind content negotiation is that the web server provides the best possible content for any user agent or web browser. It can provide certain types of image files or other content to clients that can support them. This is useful when hosting multiple versions of a file to support multiple browsing platforms, such as mobile devices.

To do all this, HTTP describes two methods of negotiating content, as well as suggesting the possibility of combining the two. One method is server-driven negotiation. With this method, the server makes the best possible decision about what to deliver, based on whatever logic is given and what content is available. .

However, there are some difficulties with server-driven content negotiation. The server doesn’t know how to respond to every possible request, so it has to make assumptions based on the logic it’s been given to make those decisions. It cannot know if the web browser is running on a mobile device or if the requested document needs to be sent directly to a printer unless told to do so. There are also privacy concerns, as the server-driven method expects the request to send information about the user making the request.

The second method is known as agent-driven content negotiation. Here, the user makes a request to the server and the server returns a list of available alternatives, if any. The selection is made automatically, based on the preferences of the browser or platform available, or manually in the form of options presented in the HTML. The main disadvantage of the agent-based option is multiple requests to the server for the best possible content. When a proxy server caches requests to a server using agent-driven negotiation, however, it will be able to serve the appropriate content to all users behind the proxy via a single request to the cache.




Protect your devices with Threat Protection by NordVPN


Skip to content