Understanding Content Negotiation


AddCharset UTF-8 .utf8 AddLanguage en .en AddEncoding gzip .gzip .gz


The HTTP protocol provides mechanisms that enable you to maintain different versions of a certain resource and return the appropriate content based on the capabilities and preferences of the client. For example, a client may inform you that he is able to accept content that is compressed and that, while its preferred language is English, it will also understand pages written in Spanish. The three main aspects that are negotiated are

  • Encoding: This is the format in which a resource is stored or represented, and can usually be determined from the file extension. For example, the file listing.txt.gz has a MIME type of text/plain and a gzip encoding. The encoding of the resource will be appended to the Content-Encoding: header of the response.

  • Character Set: This property describes the particular character set used by a document. The character set of the resource will be appended to the Content-Type: header of the response, together with the MIME type.

  • Language: You can provide different versions of the same resource. For example, the Apache documentation provides index.html.en, index.html.es, index.html.de, and so on. The language of the resource will be appended to the Content-Language: header of the response.

The example explains how you can associate charsets, languages, and encodings with particular file extensions.




Apache(c) Phrase Book(c) Essential Code and Commands
Apache Phrasebook
ISBN: 0672328364
EAN: 2147483647
Year: 2006
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net