2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.xsl"?>
6 <name>mod_negotiation</name>
7 <description>Provides for <a
8 href="../content-negotiation.html">content negotiation</a></description>
10 <sourcefile>mod_negotiation.c</sourcefile>
11 <identifier>negotiation_module</identifier>
14 <p>Content negotiation, or more accurately content selection, is
15 the selection of the document that best matches the clients
16 capabilities, from one of several available documents. There
17 are two implementations of this.</p>
20 <li>A type map (a file with the handler
21 <code>type-map</code>) which explicitly lists the files
22 containing the variants.</li>
24 <li>A MultiViews search (enabled by the MultiViews <directive
25 module="core">Options</directive>, where the server does an
26 implicit filename pattern match, and choose from amongst the
31 <seealso><directive module="mod_mime">DefaultLangauge</directive></seealso>
32 <seealso><directive module="mod_mime">AddEncoding</directive></seealso>
33 <seealso><directive module="mod_mime">AddLanguage</directive></seealso>
34 <seealso><directive module="mod_mime">AddType</directive></seealso>
36 <section><title>Type maps</title>
37 <p>A type map has the same format as RFC822 mail headers. It
38 contains document descriptions separated by blank lines, with
39 lines beginning with a hash character ('#') treated as
40 comments. A document description consists of several header
41 records; records may be continued on multiple lines if the
42 continuation lines start with spaces. The leading space will be
43 deleted and the lines concatenated. A header record consists of
44 a keyword name, which always ends in a colon, followed by a
45 value. Whitespace is allowed between the header name and value,
46 and between the tokens of value. The headers allowed are: </p>
49 <dt>Content-Encoding:</dt>
51 <dd>The encoding of the file. Apache only recognizes
52 encodings that are defined by an <directive
53 module="mod_mime">AddEncoding</directive> directive.
54 This normally includes the encodings <code>x-compress</code>
55 for compress'd files, and <code>x-gzip</code> for gzip'd
56 files. The <code>x-</code> prefix is ignored for encoding
59 <dt>Content-Language:</dt>
61 <dd>The language of the variant, as an Internet standard
62 language tag (RFC 1766). An example is <code>en</code>,
65 <dt>Content-Length:</dt>
67 <dd>The length of the file, in bytes. If this header is not
68 present, then the actual length of the file is used.</dd>
70 <dt>Content-Type:</dt>
73 The MIME media type of the document, with optional
74 parameters. Parameters are separated from the media type
75 and from one another by a semi-colon, with a syntax of
76 <code>name=value</code>. Common parameters include:
81 <dd>an integer specifying the version of the media type.
82 For <code>text/html</code> this defaults to 2, otherwise
87 <dd>a floating-point number with a value in the range 0.0
88 to 1.0, indicating the relative 'quality' of this variant
89 compared to the other available variants, independent of
90 the client's capabilities. For example, a jpeg file is
91 usually of higher source quality than an ascii file if it
92 is attempting to represent a photograph. However, if the
93 resource being represented is ascii art, then an ascii
94 file would have a higher source quality than a jpeg file.
95 All qs values are therefore specific to a given
101 <code>Content-Type: image/jpeg; qs=0.8</code>
107 <dd>The path to the file containing this variant, relative to
112 <section><title>MultiViews</title>
114 <p>A MultiViews search is enabled by the MultiViews <directive
115 module="core">Options</directive>. If the server receives a
116 request for <code>/some/dir/foo</code> and
117 <code>/some/dir/foo</code> does <em>not</em> exist, then the
118 server reads the directory looking for all files named
119 <code>foo.*</code>, and effectively fakes up a type map which
120 names all those files, assigning them the same media types and
121 content-encodings it would have if the client had asked for one
122 of them by name. It then chooses the best match to the client's
123 requirements, and returns that document.</p>
127 <name>CacheNegotiatedDocs</name>
128 <description>Allows content-negotiated documents to be
129 cached by proxy servers</description>
130 <syntax>CacheNegotiatedDocs on|off</syntax>
131 <default>CacheNegotiatedDocs off</default>
132 <contextlist><context>server config</context></contextlist>
133 <compatibility>The syntax changed in version 2.0.</compatibility>
136 <p>If set, this directive allows content-negotiated documents
137 to be cached by proxy servers. This could mean that clients
138 behind those proxys could retrieve versions of the documents
139 that are not the best match for their abilities, but it will
140 make caching more efficient.</p>
142 <p>This directive only applies to requests which come from
143 HTTP/1.0 browsers. HTTP/1.1 provides much better control over
144 the caching of negotiated documents, and this directive has no
145 effect in responses to HTTP/1.1 requests.</p>
147 <p>Prior to version 2.0,
148 <directive>CacheNegotiatedDocs</directive> did not take an
149 argument; it was turned on by the presence of the directive by
155 <name>ForceLangaugePriority</name>
156 <description>Action to take if a single acceptable document is not
158 <syntax>ForceLanguagePriority None|Prefer|Fallback [Prefer|Fallback]</syntax>
159 <default>ForceLangaugePriority None</default>
160 <contextlist><context>server config</context>
161 <context>virtual host</context>
162 <context>directory</context>
163 <context>.htaccess</context>
165 <override>FileInfo</override>
166 <compatibility>Available in version 2.0.30 and later</compatibility>
169 <p>The <directive>ForceLanguagePriority</directive> directive uses
171 module="mod_negotiation">LanguagePriority</directive> to satisfy
172 negotation where the server could otherwise not return a single
173 matching document.</p>
175 <p><code>ForceLanguagePriority Prefer</code> uses
176 <code>LanguagePriority</code> to serve a one valid result, rather
177 than returning an HTTP result 300 (MULTIPLE CHOICES) when there
178 are several equally valid choices. If the directives below were
179 given, and the user's Accept-Language header assigned en and de
180 each as quality .500 (equally acceptable) then then first matching
181 variant, en, will be served.</p>
184 LanguagePriority en fr de<br />
185 ForceLanguagePriority Prefer
188 <p><code>ForceLanguagePriority Fallback</code> uses
189 <code>LanguagePriority</code> to serve a valid result, rather than
190 returning an HTTP result 406 (NOT ACCEPTABLE). If the directives
191 below were given, and the user's Accept-Language only permitted an
192 es langauge response, but such a variant isn't found, then the
193 first variant from the LanguagePriority list below will be
197 LanguagePriority en fr de<br />
198 ForceLanguagePriority Fallback
201 <p>Both options, Prefer and Fallback, may be specified, so either the
202 first matching variant from LanguagePriority will be served if more
203 that one variant is acceptable, or first available document will be
204 served if none of the variants matched the client's acceptable list of
210 <name>LanguagePriority</name>
211 <description>The precendence of language variants for cases where
212 the client does not express a preference</description>
213 <syntax>LanguagePriority <em>MIME-lang</em> [<em>MIME-lang</em>] ...</syntax>
214 <contextlist><context>server config</context>
215 <context>virtual host</context>
216 <context>directory</context>
217 <context>.htaccess</context>
219 <override>FileInfo</override>
222 <p>The <directive>LanguagePriority</directive> sets the precedence
223 of language variants for the case where the client does not
224 express a preference, when handling a MultiViews request. The list
225 of <em>MIME-lang</em> are in order of decreasing preference.
228 <example>LanguagePriority en fr de</example>
230 <p>For a request for <code>foo.html</code>, where
231 <code>foo.html.fr</code> and <code>foo.html.de</code> both
232 existed, but the browser did not express a language preference,
233 then <code>foo.html.fr</code> would be returned.</p>
235 <p>Note that this directive only has an effect if a 'best'
236 language cannot be determined by any other means or the <directive
237 module="mod_negotiation">ForceLanguagePriority</directive> directive
238 is not <code>None</code>. Correctly implemented HTTP/1.1 requests
239 will mean this directive has no effect.</p>