mod_negotiation.html revision 049507d9fe38f0e005c97b2cc5ffb0d2636671d8
688N/A<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
1619N/A "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
688N/A
688N/A<html xmlns="http://www.w3.org/1999/xhtml">
919N/A <head>
919N/A <meta name="generator" content="HTML Tidy, see www.w3.org" />
919N/A
919N/A <title>Apache module mod_negotiation</title>
919N/A </head>
919N/A <!-- Background white, links blue (unvisited), navy (visited), red (active) -->
919N/A
919N/A <body bgcolor="#FFFFFF" text="#000000" link="#0000FF"
919N/A vlink="#000080" alink="#FF0000">
919N/A <!--#include virtual="header.html" -->
919N/A
919N/A <h1 align="CENTER">Module mod_negotiation</h1>
919N/A
919N/A <p>This module provides for <a
919N/A href="/content-negotiation.html">content negotiation</a>.</p>
919N/A
919N/A <p><a href="module-dict.html#Status"
688N/A rel="Help"><strong>Status:</strong></a> Base<br />
688N/A <a href="module-dict.html#SourceFile"
1408N/A rel="Help"><strong>Source File:</strong></a>
1408N/A mod_negotiation.c<br />
1408N/A <a href="module-dict.html#ModuleIdentifier"
1408N/A rel="Help"><strong>Module Identifier:</strong></a>
962N/A negotiation_module</p>
688N/A
688N/A <h2>Summary</h2>
688N/A Content negotiation, or more accurately content selection, is
688N/A the selection of the document that best matches the clients
688N/A capabilities, from one of several available documents. There
688N/A are two implementations of this.
688N/A
962N/A <ul>
719N/A <li>A type map (a file with the handler
719N/A <code>type-map</code>) which explicitly lists the files
719N/A containing the variants.</li>
962N/A
962N/A <li>A MultiViews search (enabled by the MultiViews <a
962N/A href="core.html#options">Option</a>, where the server does an
962N/A implicit filename pattern match, and choose from amongst the
962N/A results.</li>
962N/A </ul>
962N/A
962N/A <h2>Directives</h2>
719N/A
719N/A <ul>
719N/A <li><a href="#cachenegotiateddocs">CacheNegotiatedDocs</a></li>
719N/A <li><a href="#forcelanguagepriority">ForceLanguagePriority</a></li>
719N/A <li><a href="#languagepriority">LanguagePriority</a></li>
719N/A </ul>
719N/A <strong>See also</strong>: <a
719N/A href="/mod_mime.html#defaultlanguage">DefaultLanguage</a>, <a
962N/A href="/mod_mime.html#addencoding">AddEncoding</a>, <a
962N/A href="/mod_mime.html#addlanguage">AddLanguage</a>, <a
962N/A href="/mod_mime.html#addtype">AddType</a>, and <a
719N/A href="core.html#options">Options</a>.
719N/A
719N/A <h2>Type maps</h2>
962N/A A type map has the same format as RFC822 mail headers. It
719N/A contains document descriptions separated by blank lines, with
719N/A lines beginning with a hash character ('#') treated as
719N/A comments. A document description consists of several header
719N/A records; records may be continued on multiple lines if the
719N/A continuation lines start with spaces. The leading space will be
719N/A deleted and the lines concatenated. A header record consists of
719N/A a keyword name, which always ends in a colon, followed by a
719N/A value. Whitespace is allowed between the header name and value,
962N/A and between the tokens of value. The headers allowed are:
719N/A
719N/A <dl>
719N/A <dt>Content-Encoding:</dt>
719N/A
719N/A <dd>The encoding of the file. Apache only recognizes
719N/A encodings that are defined by an <a
719N/A href="mod_mime.html#addencoding">AddEncoding</a> directive.
719N/A This normally includes the encodings <code>x-compress</code>
962N/A for compress'd files, and <code>x-gzip</code> for gzip'd
719N/A files. The <code>x-</code> prefix is ignored for encoding
719N/A comparisons.</dd>
719N/A
719N/A <dt>Content-Language:</dt>
719N/A
719N/A <dd>The language of the variant, as an Internet standard
719N/A language tag (RFC 1766). An example is <code>en</code>,
719N/A meaning English.</dd>
962N/A
719N/A <dt>Content-Length:</dt>
719N/A
719N/A <dd>The length of the file, in bytes. If this header is not
719N/A present, then the actual length of the file is used.</dd>
719N/A
719N/A <dt>Content-Type:</dt>
719N/A
719N/A <dd>
719N/A The MIME media type of the document, with optional
719N/A parameters. Parameters are separated from the media type
719N/A and from one another by a semi-colon, with a syntax of
719N/A <code>name=value</code>. Common parameters include:
719N/A
719N/A <dl>
719N/A <dt>level</dt>
719N/A
719N/A <dd>an integer specifying the version of the media type.
719N/A For <code>text/html</code> this defaults to 2, otherwise
719N/A 0.</dd>
719N/A
962N/A <dt>qs</dt>
719N/A
719N/A <dd>a floating-point number with a value in the range 0.0
688N/A to 1.0, indicating the relative 'quality' of this variant
719N/A compared to the other available variants, independent of
719N/A the client's capabilities. For example, a jpeg file is
688N/A usually of higher source quality than an ascii file if it
688N/A is attempting to represent a photograph. However, if the
688N/A resource being represented is ascii art, then an ascii
688N/A file would have a higher source quality than a jpeg file.
688N/A All qs values are therefore specific to a given
688N/A resource.</dd>
688N/A </dl>
688N/A Example:
688N/A
688N/A <blockquote>
719N/A <code>Content-Type: image/jpeg; qs=0.8</code>
719N/A </blockquote>
719N/A </dd>
719N/A
719N/A <dt>URI:</dt>
962N/A
719N/A <dd>The path to the file containing this variant, relative to
719N/A the map file.</dd>
719N/A </dl>
719N/A
719N/A <h2>MultiViews</h2>
719N/A A MultiViews search is enabled by the MultiViews <a
719N/A href="core.html#options">Option</a>. If the server receives a
719N/A request for <code>/some/dir/foo</code> and
962N/A <code>/some/dir/foo</code> does <em>not</em> exist, then the
688N/A server reads the directory looking for all files named
688N/A <code>foo.*</code>, and effectively fakes up a type map which
688N/A names all those files, assigning them the same media types and
688N/A content-encodings it would have if the client had asked for one
719N/A of them by name. It then chooses the best match to the client's
688N/A requirements, and returns that document.
688N/A <hr />
688N/A
688N/A <h2><a id="cachenegotiateddocs"
688N/A name="cachenegotiateddocs">CacheNegotiatedDocs</a>
688N/A directive</h2>
688N/A <a href="directive-dict.html#Syntax"
688N/A rel="Help"><strong>Syntax:</strong></a> CacheNegotiatedDocs
688N/A on|off<br />
719N/A <a href="directive-dict.html#Default"
688N/A rel="Help"><strong>Default:</strong></a>
688N/A <code>CacheNegotiatedDocs off</code><br />
688N/A <a href="directive-dict.html#Context"
688N/A rel="Help"><strong>Context:</strong></a> server config<br />
688N/A <a href="directive-dict.html#Status"
688N/A rel="Help"><strong>Status:</strong></a> Base<br />
688N/A <a href="directive-dict.html#Module"
688N/A rel="Help"><strong>Module:</strong></a> mod_negotiation<br />
688N/A <a href="directive-dict.html#Compatibility"
719N/A rel="Help"><strong>Compatibility:</strong></a>
688N/A CacheNegotiatedDocs is only available in Apache 1.1 and later.
688N/A The syntax changed in version 2.0.
688N/A
688N/A <p>If set, this directive allows content-negotiated documents
688N/A to be cached by proxy servers. This could mean that clients
688N/A behind those proxys could retrieve versions of the documents
688N/A that are not the best match for their abilities, but it will
688N/A make caching more efficient.</p>
688N/A
719N/A <p>This directive only applies to requests which come from
688N/A HTTP/1.0 browsers. HTTP/1.1 provides much better control over
688N/A the caching of negotiated documents, and this directive has no
688N/A effect in responses to HTTP/1.1 requests.</p>
688N/A
688N/A <p>Prior to version 2.0, CacheNegotiatedDocs did not take an
688N/A argument; it was turned on by the presence of the directive by
688N/A itself.</p>
688N/A <hr />
688N/A
719N/A <h2><a id="forcelanguagepriority"
688N/A name="forcelanguagepriority">ForceLanguagePriority</a> directive</h2>
688N/A <p><a href="directive-dict.html#Syntax"
688N/A rel="Help"><strong>Syntax:</strong></a> ForceLanguagePriority
688N/A None|Prefer|Fallback [Prefer|Fallback]<br />
688N/A <a href="directive-dict.html#Default"
688N/A rel="Help"><strong>Default:</strong></a>
688N/A <code>ForceLanguagePriority None</code><br />
688N/A <a href="directive-dict.html#Context"
719N/A rel="Help"><strong>Context:</strong></a> server config, virtual
719N/A host, directory, .htaccess<br />
688N/A <a href="directive-dict.html#Override"
688N/A rel="Help"><strong>Override:</strong></a> FileInfo<br />
719N/A <a href="directive-dict.html#Status"
688N/A rel="Help"><strong>Status:</strong></a> Base<br />
688N/A <a href="directive-dict.html#Module"
688N/A rel="Help"><strong>Module:</strong></a> mod_negotiation<br />
688N/A <a href="directive-dict.html#Compatibility"
688N/A rel="Help"><strong>Compatibility:</strong></a>
688N/A Available in version 2.0.30 and later.</p>
688N/A
688N/A <p>The <code>ForceLanguagePriority</code> directive uses the given
688N/A <a href="#languagepriority">LanguagePriority</a> to satisfy
719N/A negotation where the server could otherwise not return a single
688N/A matching document.</p>
688N/A
688N/A <p><code>ForceLanguagePriority Prefer</code> uses
962N/A <code>LanguagePriority</code> to serve a one valid result, rather
719N/A than returning an HTTP result 300 (MULTIPLE CHOICES) when there
719N/A are several equally valid choices. If the directives below were
719N/A given, and the user's Accept-Language header assigned en and de
719N/A each as quality .500 (equally acceptable) then then first matching
719N/A variant, en, will be served.</p>
719N/A
719N/A <blockquote><code>
719N/A LanguagePriority en fr de<br />
719N/A ForceLanguagePriority Prefer
719N/A </code></blockquote>
719N/A
719N/A <p><code>ForceLanguagePriority Fallback</code> uses
719N/A <code>LanguagePriority</code> to serve a valid result, rather than
719N/A returning an HTTP result 406 (NOT ACCEPTABLE). If the directives
719N/A below were given, and the user's Accept-Language only permitted an
719N/A es langauge response, but such a variant isn't found, then the
719N/A first variant from the LanguagePriority list below will be
719N/A served.</p>
719N/A
719N/A <blockquote><code>
719N/A LanguagePriority en fr de<br />
719N/A ForceLanguagePriority Fallback
719N/A </code></blockquote>
719N/A
719N/A <p>Both options, Prefer and Fallback, may be specified, so either the
719N/A first matching variant from LanguagePriority will be served if more
719N/A that one variant is acceptable, or first available document will be
719N/A served if none of the variants matched the client's acceptable list of
719N/A languages.</p>
719N/A
719N/A <hr />
719N/A
719N/A <h2><a id="languagepriority"
719N/A name="languagepriority">LanguagePriority</a> directive</h2>
719N/A <!--%plaintext &lt;?INDEX {\tt LanguagePriority} directive&gt; -->
719N/A <a href="directive-dict.html#Syntax"
719N/A rel="Help"><strong>Syntax:</strong></a> LanguagePriority
719N/A <em>MIME-lang</em> [<em>MIME-lang</em>] ...<br />
719N/A <a href="directive-dict.html#Context"
719N/A rel="Help"><strong>Context:</strong></a> server config, virtual
719N/A host, directory, .htaccess<br />
719N/A <a href="directive-dict.html#Override"
719N/A rel="Help"><strong>Override:</strong></a> FileInfo<br />
719N/A <a href="directive-dict.html#Status"
719N/A rel="Help"><strong>Status:</strong></a> Base<br />
719N/A <a href="directive-dict.html#Module"
719N/A rel="Help"><strong>Module:</strong></a> mod_negotiation
719N/A
719N/A <p>The LanguagePriority sets the precedence of language
719N/A variants for the case where the client does not express a
719N/A preference, when handling a MultiViews request. The list of
719N/A <em>MIME-lang</em> are in order of decreasing preference.
719N/A Example:</p>
719N/A
719N/A <blockquote>
719N/A <code>LanguagePriority en fr de</code>
719N/A </blockquote>
719N/A For a request for <code>foo.html</code>, where
719N/A <code>foo.html.fr</code> and <code>foo.html.de</code> both
719N/A existed, but the browser did not express a language preference,
719N/A then <code>foo.html.fr</code> would be returned.
719N/A
719N/A <p>Note that this directive only has an effect if a 'best'
719N/A language cannot be determined by any other means or the <a
719N/A href="#forcelanguagepriority">ForceLanguagePriority</a> directive
719N/A is not <code>None</code>. Correctly implemented HTTP/1.1 requests
719N/A will mean this directive has no effect.</p>
719N/A
719N/A <p><strong>See also</strong>: <a
688N/A href="/mod_mime.html#defaultlanguage">DefaultLanguage</a>,
688N/A <a href="/mod_mime.html#addlanguage">AddLanguage</a> and
688N/A <a href="#forcelanguagepriority">ForceLanguagePriority</a>.
688N/A <!--#include virtual="footer.html" -->
688N/A </p>
688N/A </body>
688N/A</html>
688N/A
719N/A