Summary
Content negotiation is the selection of the document that best matches the clients capabilities from one of several available documents. There are two implementations of content negotiation:
See Content negotiation for HTTP Server (powered by Apache) for more information.
Type maps
A type map has the same format as RFC822 mail headers. It contains document descriptions separated by blank lines, with lines beginning with a pound sign ('#') are treated as comments. A document description consists of several header records. Records may be continued on multiple lines if the continuation lines start with spaces. The leading space will be deleted and the lines concatenated. A header record consists of a keyword name, which always ends in a colon, followed by a value. Whitespace is allowed between the header name and value, and between the tokens of value. The headers allowed are:
Header | Description |
---|---|
Content-Encoding | The encoding of the file. The server only recognizes encoding that is defined by an AddEncoding directive. This normally includes the encoding x-compress for compress'ed files, and x-gzip for gzip'ed files. The x- prefix is ignored for encoding comparisons. |
Content-Language | The language of the variant, as an Internet standard language tag (RFC 1766). An example is en, meaning English. |
Content-Length | The length of the file, in bytes. If this header is not present, then the actual length of the file is used. |
Content-Type | The MIME media type of the document, with optional parameters.
Parameters are separated from the media type and from one another by a semicolon,
with a syntax of name=value. Common parameters include:
|
URL | The path to the file containing this variant, relative to the map file. |
MultiViews
A MultiViews search is enabled by the MultiViews Option. If the server receives a request for /some/dir/QIBM and /some/dir/QIBM does not exist, then the server reads the directory looking for all files named QIBM.* , and effectively makes up a type map which names all those files, assigning them the same media types and content-encodings it would have if the client had asked for one of them by name. It then chooses the best match to the client's requirements, and returns that document.
Directives
Module: mod_negotiation | |
Syntax: CacheNegotiatedDocs on | off | |
Default: CacheNegotiatedDocs off | |
Context: server config, virtual host | |
Override: none | |
Origin: Apache | |
Example: CacheNegotiatedDocs on |
The CacheNegotiatedDocs directive allows content-negotiated documents requested using HTTP/1.0 to be cached by proxy servers.
Module: mod_negotiation | |
Syntax: ForceLanguagePriority None | Prefer | Fallback [Prefer | Fallback] | |
Default: ForceLanguagePriority None | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: See below. |
The ForceLanguagePriority directive uses the given LanguagePriority to satisfy negotiation where the server could otherwise not return a single matching document.
LanguagePriority en Fr de ForceLanguagePriority Prefer
LanguagePriority en Fr de ForceLanguagePriority Fallback
Both options, Prefer and Fallback, may be specified, so either the first matching variant from LanguagePriority will be served if more that one variant is acceptable, or the first available document will be served if none of the variants match the client's acceptable list of languages.
See DefaultLanguage, AddLanguage and LanguagePriorityfor more information.
Module: mod_negotiation | |
Syntax: LanguagePriority MIME-lang [MIME-lang...] | |
Default: none | |
Context: server config, virtual host, directory, .htaccess | |
Override: FileInfo | |
Origin: Apache | |
Example: LanguagePriority en Fr de |
The LanguagePriority directive sets the precedence of language variants for the case where the client does not express a preference when handling a MultiViews request. The list of MIME-lang are in order of decreasing preference.
This directive may be configured multiple times in a container. The directives are processed from the first to the last occurrence.