Moved apache code into a folder to help prepare for packaging where we dont want...
[httpd-crcsyncproxy.git] / apache / docs / manual / mod / mod_negotiation.xml
blobc965b37cf76d0d0d9f8aa2c59f48d6bdde108ace
1 <?xml version="1.0"?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
14      http://www.apache.org/licenses/LICENSE-2.0
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
23 <modulesynopsis metafile="mod_negotiation.xml.meta">
25 <name>mod_negotiation</name>
26 <description>Provides for <a
27     href="../content-negotiation.html">content negotiation</a></description>
28 <status>Base</status>
29 <sourcefile>mod_negotiation.c</sourcefile>
30 <identifier>negotiation_module</identifier>
32 <summary>
33     <p>Content negotiation, or more accurately content selection, is
34     the selection of the document that best matches the clients
35     capabilities, from one of several available documents. There
36     are two implementations of this.</p>
38     <ul>
39       <li>A type map (a file with the handler
40       <code>type-map</code>) which explicitly lists the files
41       containing the variants.</li>
43       <li>A MultiViews search (enabled by the <code>MultiViews</code>
44       <directive module="core">Options</directive>), where the server does
45       an implicit filename pattern match, and choose from amongst the
46       results.</li>
47     </ul>
48 </summary>
49 <seealso><directive module="core">Options</directive></seealso>
50 <seealso><module>mod_mime</module></seealso>
51 <seealso><a href="../content-negotiation.html">Content
52 Negotiation</a></seealso>
53 <seealso><a href="../env.html">Environment Variables</a></seealso>
55 <section id="typemaps"><title>Type maps</title>
56     <p>A type map has a format similar to RFC822 mail headers. It
57     contains document descriptions separated by blank lines, with
58     lines beginning with a hash character ('#') treated as
59     comments. A document description consists of several header
60     records; records may be continued on multiple lines if the
61     continuation lines start with spaces. The leading space will be
62     deleted and the lines concatenated. A header record consists of
63     a keyword name, which always ends in a colon, followed by a
64     value. Whitespace is allowed between the header name and value,
65     and between the tokens of value. The headers allowed are: </p>
67     <dl>
68       <dt><code>Content-Encoding:</code></dt>
69       <dd>The encoding of the file. Apache only recognizes
70       encodings that are defined by an <directive
71       module="mod_mime">AddEncoding</directive> directive.
72       This normally includes the encodings <code>x-compress</code>
73       for compress'd files, and <code>x-gzip</code> for gzip'd
74       files. The <code>x-</code> prefix is ignored for encoding
75       comparisons.</dd>
77       <dt><code>Content-Language:</code></dt>
78       <dd>The language(s) of the variant, as an Internet standard
79       language tag (<a href="http://www.ietf.org/rfc/rfc1766.txt"
80       >RFC 1766</a>). An example is <code>en</code>,
81       meaning English. If the variant contains more than one
82       language, they are separated by a comma.</dd>
84       <dt><code>Content-Length:</code></dt>
85       <dd>The length of the file, in bytes. If this header is not
86       present, then the actual length of the file is used.</dd>
88       <dt><code>Content-Type:</code></dt>
90       <dd>
91         The <glossary ref="mime-type">MIME media type</glossary> of
92         the document, with optional parameters. Parameters are
93         separated from the media type and from one another by a
94         semi-colon, with a syntax of <code>name=value</code>. Common
95         parameters include:
97         <dl>
98           <dt><code>level</code></dt>
99           <dd>an integer specifying the version of the media type.
100           For <code>text/html</code> this defaults to 2, otherwise
101           0.</dd>
103           <dt><code>qs</code></dt>
104           <dd>a floating-point number with a value in the range 0.0
105           to 1.0, indicating the relative 'quality' of this variant
106           compared to the other available variants, independent of
107           the client's capabilities. For example, a jpeg file is
108           usually of higher source quality than an ascii file if it
109           is attempting to represent a photograph. However, if the
110           resource being represented is ascii art, then an ascii
111           file would have a higher source quality than a jpeg file.
112           All <code>qs</code> values are therefore specific to a given
113           resource.</dd>
114         </dl>
116         <example><title>Example</title>
117           Content-Type: image/jpeg; qs=0.8
118         </example>
119       </dd>
121       <dt><code>URI:</code></dt>
122       <dd>uri of the file containing the variant (of the given
123       media type, encoded with the given content encoding). These
124       are interpreted as URLs relative to the map file; they must
125       be on the same server (!), and they must refer to files to
126       which the client would be granted access if they were to be
127       requested directly.</dd>
129       <dt><code>Body:</code></dt>
130       <dd>New in Apache 2.0, the actual content of the resource may
131       be included in the type-map file using the Body header.  This
132       header must contain a string that designates a delimiter for
133       the body content. Then all following lines in the type map
134       file will be considered part of the resource body until the
135       delimiter string is found.
137       <example><title>Example:</title>
138         Body:----xyz----<br />
139         &lt;html&gt;<br />
140         &lt;body&gt;<br />
141         &lt;p&gt;Content of the page.&lt;/p&gt;<br />
142         &lt;/body&gt;<br />
143         &lt;/html&gt;<br />
144         ----xyz----
145       </example>
146       </dd>
147     </dl>
148 </section>
150 <section id="multiviews"><title>MultiViews</title>
151     <p>A MultiViews search is enabled by the <code>MultiViews</code>
152     <directive module="core">Options</directive>. If the server receives a
153     request for <code>/some/dir/foo</code> and
154     <code>/some/dir/foo</code> does <em>not</em> exist, then the
155     server reads the directory looking for all files named
156     <code>foo.*</code>, and effectively fakes up a type map which
157     names all those files, assigning them the same media types and
158     content-encodings it would have if the client had asked for one
159     of them by name. It then chooses the best match to the client's
160     requirements, and returns that document.</p>
162     <p>The <directive module="mod_mime">MultiViewsMatch</directive>
163     directive configures whether Apache will consider files
164     that do not have content negotiation meta-information assigned
165     to them when choosing files.</p>
166 </section>
168 <directivesynopsis>
169 <name>CacheNegotiatedDocs</name>
170 <description>Allows content-negotiated documents to be 
171 cached by proxy servers</description>
172 <syntax>CacheNegotiatedDocs On|Off</syntax>
173 <default>CacheNegotiatedDocs Off</default>
174 <contextlist><context>server config</context><context>virtual host</context>
175 </contextlist>
176 <compatibility>The syntax changed in version 2.0.</compatibility>
178 <usage>
179     <p>If set, this directive allows content-negotiated documents
180     to be cached by proxy servers. This could mean that clients
181     behind those proxys could retrieve versions of the documents
182     that are not the best match for their abilities, but it will
183     make caching more efficient.</p>
185     <p>This directive only applies to requests which come from
186     HTTP/1.0 browsers. HTTP/1.1 provides much better control over
187     the caching of negotiated documents, and this directive has no
188     effect in responses to HTTP/1.1 requests.</p>
190     <p>Prior to version 2.0,
191     <directive>CacheNegotiatedDocs</directive> did not take an
192     argument; it was turned on by the presence of the directive by
193     itself.</p>
194 </usage>
195 </directivesynopsis>
197 <directivesynopsis>
198 <name>ForceLanguagePriority</name>
199 <description>Action to take if a single acceptable document is not 
200 found</description>
201 <syntax>ForceLanguagePriority None|Prefer|Fallback [Prefer|Fallback]</syntax>
202 <default>ForceLanguagePriority Prefer</default>
203 <contextlist><context>server config</context><context>virtual host</context>
204 <context>directory</context><context>.htaccess</context></contextlist>
205 <override>FileInfo</override>
206 <compatibility>Available in version 2.0.30 and later</compatibility>
208 <usage>
209     <p>The <directive>ForceLanguagePriority</directive> directive uses
210     the given <directive
211     module="mod_negotiation">LanguagePriority</directive> to satisfy
212     negotation where the server could otherwise not return a single
213     matching document.</p>
215     <p><code>ForceLanguagePriority Prefer</code> uses
216     <code>LanguagePriority</code> to serve a one valid result, rather
217     than returning an HTTP result 300 (MULTIPLE CHOICES) when there
218     are several equally valid choices.  If the directives below were
219     given, and the user's <code>Accept-Language</code> header assigned
220     <code>en</code> and <code>de</code> each as quality <code>.500</code>
221     (equally acceptable) then the first matching variant, <code>en</code>,
222     will be served.</p>
224     <example>
225       LanguagePriority en fr de<br />
226       ForceLanguagePriority Prefer
227     </example>
229     <p><code>ForceLanguagePriority Fallback</code> uses
230     <directive module="mod_negotiation">LanguagePriority</directive> to
231     serve a valid result, rather than returning an HTTP result 406
232     (NOT ACCEPTABLE). If the directives below were given, and the user's
233     <code>Accept-Language</code> only permitted an <code>es</code>
234     language response, but such a variant isn't found, then the first
235     variant from the <directive module="mod_negotiation"
236     >LanguagePriority</directive> list below will be served.</p>
238     <example>
239       LanguagePriority en fr de<br />
240       ForceLanguagePriority Fallback
241     </example>
243     <p>Both options, <code>Prefer</code> and <code>Fallback</code>, may be
244     specified, so either the first matching variant from <directive
245     module="mod_negotiation">LanguagePriority</directive> will be served if
246     more than one variant is acceptable, or first available document will
247     be served if none of the variants matched the client's acceptable list
248     of languages.</p>
249 </usage>
250 <seealso><directive module="mod_mime">AddLanguage</directive></seealso>
251 </directivesynopsis>
253 <directivesynopsis>
254 <name>LanguagePriority</name>
255 <description>The precendence of language variants for cases where
256 the client does not express a preference</description>
257 <syntax>LanguagePriority <var>MIME-lang</var> [<var>MIME-lang</var>]
258 ...</syntax>
259 <contextlist><context>server config</context><context>virtual host</context>
260 <context>directory</context><context>.htaccess</context></contextlist>
261 <override>FileInfo</override>
263 <usage>
264     <p>The <directive>LanguagePriority</directive> sets the precedence
265     of language variants for the case where the client does not
266     express a preference, when handling a MultiViews request. The list
267     of <var>MIME-lang</var> are in order of decreasing preference.</p>
269     <example><title>Example:</title>
270       LanguagePriority en fr de
271     </example>
273     <p>For a request for <code>foo.html</code>, where
274     <code>foo.html.fr</code> and <code>foo.html.de</code> both
275     existed, but the browser did not express a language preference,
276     then <code>foo.html.fr</code> would be returned.</p>
278     <p>Note that this directive only has an effect if a 'best'
279     language cannot be determined by any other means or the <directive
280     module="mod_negotiation">ForceLanguagePriority</directive> directive
281     is not <code>None</code>. In general, the client determines the
282     language preference, not the server.</p>
283 </usage>
284 <seealso><directive module="mod_mime">AddLanguage</directive></seealso>
285 </directivesynopsis>
287 </modulesynopsis>