2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
7 Copyright 2002-2004 The Apache Software Foundation
9 Licensed under the Apache License, Version 2.0 (the "License");
10 you may not use this file except in compliance with the License.
11 You may obtain a copy of the License at
13 http://www.apache.org/licenses/LICENSE-2.0
15 Unless required by applicable law or agreed to in writing, software
16 distributed under the License is distributed on an "AS IS" BASIS,
17 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 See the License for the specific language governing permissions and
19 limitations under the License.
22 <modulesynopsis metafile="mod_negotiation.xml.meta">
24 <name>mod_negotiation</name>
25 <description>Provides for <a
26 href="../content-negotiation.html">content negotiation</a></description>
28 <sourcefile>mod_negotiation.c</sourcefile>
29 <identifier>negotiation_module</identifier>
32 <p>Content negotiation, or more accurately content selection, is
33 the selection of the document that best matches the clients
34 capabilities, from one of several available documents. There
35 are two implementations of this.</p>
38 <li>A type map (a file with the handler
39 <code>type-map</code>) which explicitly lists the files
40 containing the variants.</li>
42 <li>A MultiViews search (enabled by the <code>MultiViews</code>
43 <directive module="core">Options</directive>), where the server does
44 an implicit filename pattern match, and choose from amongst the
48 <seealso><directive module="core">Options</directive></seealso>
49 <seealso><module>mod_mime</module></seealso>
50 <seealso><a href="../content-negotiation.html">Content
51 Negotiation</a></seealso>
52 <seealso><a href="../env.html">Environment Variables</a></seealso>
54 <section id="typemaps"><title>Type maps</title>
55 <p>A type map has a format similar to RFC822 mail headers. It
56 contains document descriptions separated by blank lines, with
57 lines beginning with a hash character ('#') treated as
58 comments. A document description consists of several header
59 records; records may be continued on multiple lines if the
60 continuation lines start with spaces. The leading space will be
61 deleted and the lines concatenated. A header record consists of
62 a keyword name, which always ends in a colon, followed by a
63 value. Whitespace is allowed between the header name and value,
64 and between the tokens of value. The headers allowed are: </p>
67 <dt><code>Content-Encoding:</code></dt>
68 <dd>The encoding of the file. Apache only recognizes
69 encodings that are defined by an <directive
70 module="mod_mime">AddEncoding</directive> directive.
71 This normally includes the encodings <code>x-compress</code>
72 for compress'd files, and <code>x-gzip</code> for gzip'd
73 files. The <code>x-</code> prefix is ignored for encoding
76 <dt><code>Content-Language:</code></dt>
77 <dd>The language(s) of the variant, as an Internet standard
78 language tag (<a href="http://www.ietf.org/rfc/rfc1766.txt"
79 >RFC 1766</a>). An example is <code>en</code>,
80 meaning English. If the variant contains more than one
81 language, they are separated by a comma.</dd>
83 <dt><code>Content-Length:</code></dt>
84 <dd>The length of the file, in bytes. If this header is not
85 present, then the actual length of the file is used.</dd>
87 <dt><code>Content-Type:</code></dt>
90 The MIME media type of the document, with optional
91 parameters. Parameters are separated from the media type
92 and from one another by a semi-colon, with a syntax of
93 <code>name=value</code>. Common parameters include:
96 <dt><code>level</code></dt>
97 <dd>an integer specifying the version of the media type.
98 For <code>text/html</code> this defaults to 2, otherwise
101 <dt><code>qs</code></dt>
102 <dd>a floating-point number with a value in the range 0.0
103 to 1.0, indicating the relative 'quality' of this variant
104 compared to the other available variants, independent of
105 the client's capabilities. For example, a jpeg file is
106 usually of higher source quality than an ascii file if it
107 is attempting to represent a photograph. However, if the
108 resource being represented is ascii art, then an ascii
109 file would have a higher source quality than a jpeg file.
110 All <code>qs</code> values are therefore specific to a given
114 <example><title>Example</title>
115 Content-Type: image/jpeg; qs=0.8
119 <dt><code>URI:</code></dt>
120 <dd>uri of the file containing the variant (of the given
121 media type, encoded with the given content encoding). These
122 are interpreted as URLs relative to the map file; they must
123 be on the same server (!), and they must refer to files to
124 which the client would be granted access if they were to be
125 requested directly.</dd>
127 <dt><code>Body:</code></dt>
128 <dd>New in Apache 2.0, the actual content of the resource may
129 be included in the type-map file using the Body header. This
130 header must contain a string that designates a delimiter for
131 the body content. Then all following lines in the type map
132 file will be considered part of the resource body until the
133 delimiter string is found.
135 <example><title>Example:</title>
136 Body:----xyz----<br />
139 <p>Content of the page.</p><br />
148 <section id="multiviews"><title>MultiViews</title>
149 <p>A MultiViews search is enabled by the <code>MultiViews</code>
150 <directive module="core">Options</directive>. If the server receives a
151 request for <code>/some/dir/foo</code> and
152 <code>/some/dir/foo</code> does <em>not</em> exist, then the
153 server reads the directory looking for all files named
154 <code>foo.*</code>, and effectively fakes up a type map which
155 names all those files, assigning them the same media types and
156 content-encodings it would have if the client had asked for one
157 of them by name. It then chooses the best match to the client's
158 requirements, and returns that document.</p>
160 <p>The <directive module="mod_mime">MultiViewsMatch</directive>
161 directive configures whether Apache will consider files
162 that do not have content negotiation meta-information assigned
163 to them when choosing files.</p>
167 <name>CacheNegotiatedDocs</name>
168 <description>Allows content-negotiated documents to be
169 cached by proxy servers</description>
170 <syntax>CacheNegotiatedDocs On|Off</syntax>
171 <default>CacheNegotiatedDocs Off</default>
172 <contextlist><context>server config</context><context>virtual host</context>
174 <compatibility>The syntax changed in version 2.0.</compatibility>
177 <p>If set, this directive allows content-negotiated documents
178 to be cached by proxy servers. This could mean that clients
179 behind those proxys could retrieve versions of the documents
180 that are not the best match for their abilities, but it will
181 make caching more efficient.</p>
183 <p>This directive only applies to requests which come from
184 HTTP/1.0 browsers. HTTP/1.1 provides much better control over
185 the caching of negotiated documents, and this directive has no
186 effect in responses to HTTP/1.1 requests.</p>
188 <p>Prior to version 2.0,
189 <directive>CacheNegotiatedDocs</directive> did not take an
190 argument; it was turned on by the presence of the directive by
196 <name>ForceLanguagePriority</name>
197 <description>Action to take if a single acceptable document is not
199 <syntax>ForceLanguagePriority None|Prefer|Fallback [Prefer|Fallback]</syntax>
200 <default>ForceLanguagePriority Prefer</default>
201 <contextlist><context>server config</context><context>virtual host</context>
202 <context>directory</context><context>.htaccess</context></contextlist>
203 <override>FileInfo</override>
204 <compatibility>Available in version 2.0.30 and later</compatibility>
207 <p>The <directive>ForceLanguagePriority</directive> directive uses
209 module="mod_negotiation">LanguagePriority</directive> to satisfy
210 negotation where the server could otherwise not return a single
211 matching document.</p>
213 <p><code>ForceLanguagePriority Prefer</code> uses
214 <code>LanguagePriority</code> to serve a one valid result, rather
215 than returning an HTTP result 300 (MULTIPLE CHOICES) when there
216 are several equally valid choices. If the directives below were
217 given, and the user's <code>Accept-Language</code> header assigned
218 <code>en</code> and <code>de</code> each as quality <code>.500</code>
219 (equally acceptable) then the first matching variant, <code>en</code>,
223 LanguagePriority en fr de<br />
224 ForceLanguagePriority Prefer
227 <p><code>ForceLanguagePriority Fallback</code> uses
228 <directive module="mod_negotiation">LanguagePriority</directive> to
229 serve a valid result, rather than returning an HTTP result 406
230 (NOT ACCEPTABLE). If the directives below were given, and the user's
231 <code>Accept-Language</code> only permitted an <code>es</code>
232 language response, but such a variant isn't found, then the first
233 variant from the <directive module="mod_negotiation"
234 >LanguagePriority</directive> list below will be served.</p>
237 LanguagePriority en fr de<br />
238 ForceLanguagePriority Fallback
241 <p>Both options, <code>Prefer</code> and <code>Fallback</code>, may be
242 specified, so either the first matching variant from <directive
243 module="mod_negotiation">LanguagePriority</directive> will be served if
244 more than one variant is acceptable, or first available document will
245 be served if none of the variants matched the client's acceptable list
248 <seealso><directive module="mod_mime">AddLanguage</directive></seealso>
252 <name>LanguagePriority</name>
253 <description>The precendence of language variants for cases where
254 the client does not express a preference</description>
255 <syntax>LanguagePriority <var>MIME-lang</var> [<var>MIME-lang</var>]
257 <contextlist><context>server config</context><context>virtual host</context>
258 <context>directory</context><context>.htaccess</context></contextlist>
259 <override>FileInfo</override>
262 <p>The <directive>LanguagePriority</directive> sets the precedence
263 of language variants for the case where the client does not
264 express a preference, when handling a MultiViews request. The list
265 of <var>MIME-lang</var> are in order of decreasing preference.</p>
267 <example><title>Example:</title>
268 LanguagePriority en fr de
271 <p>For a request for <code>foo.html</code>, where
272 <code>foo.html.fr</code> and <code>foo.html.de</code> both
273 existed, but the browser did not express a language preference,
274 then <code>foo.html.fr</code> would be returned.</p>
276 <p>Note that this directive only has an effect if a 'best'
277 language cannot be determined by any other means or the <directive
278 module="mod_negotiation">ForceLanguagePriority</directive> directive
279 is not <code>None</code>. In general, the client determines the
280 language preference, not the server.</p>
282 <seealso><directive module="mod_mime">AddLanguage</directive></seealso>