mod_negotiation.html revision 28f941dee822293ec6ff53e74ee8cf2aaa46251c
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<HTML>
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<HEAD>
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<TITLE>Apache module mod_negotiation</TITLE>
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder</HEAD>
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<!-- Background white, links blue (unvisited), navy (visited), red (active) -->
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<BODY
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder BGCOLOR="#FFFFFF"
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder TEXT="#000000"
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder LINK="#0000FF"
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder VLINK="#000080"
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder ALINK="#FF0000"
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder>
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<!--#include virtual="header.html" -->
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<H1 ALIGN="CENTER">Module mod_negotiation</H1>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<p>This module provides for <A
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian MaederHREF="/content-negotiation.html">content negotiation</A>.</p>
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<P><A
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian MaederHREF="module-dict.html#Status"
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian MaederREL="Help"
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder><STRONG>Status:</STRONG></A> Base
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<BR>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<A
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian MaederHREF="module-dict.html#SourceFile"
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian MaederREL="Help"
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder><STRONG>Source File:</STRONG></A> mod_negotiation.c
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<BR>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<A
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian MaederHREF="module-dict.html#ModuleIdentifier"
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian MaederREL="Help"
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder><STRONG>Module Identifier:</STRONG></A> negotiation_module
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder</P>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<H2>Summary</H2>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian MaederContent negotiation, or more accurately content selection, is the
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maederselection of the document that best matches the clients
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maedercapabilities, from one of several available documents.
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian MaederThere are two implementations of this.
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<UL>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<LI> A type map (a file with the handler <CODE>type-map</CODE>)
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maederwhich explicitly lists the files containing the variants.
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<LI> A MultiViews search (enabled by the MultiViews
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<A HREF="core.html#options">Option</A>, where the server does an implicit
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maederfilename pattern match, and choose from amongst the results.
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder</UL>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<H2>Directives</H2>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<UL>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<LI><A HREF="#cachenegotiateddocs">CacheNegotiatedDocs</A>
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maeder<LI><A HREF="#languagepriority">LanguagePriority</A>
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder</UL>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<STRONG>See also</STRONG>:
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<A HREF="/mod_mime.html#defaultlanguage">DefaultLanguage</A>,
a94f7b3982dccd2e01bd87f64de1aeab6edac118Christian Maeder<A HREF="/mod_mime.html#addencoding">AddEncoding</A>,
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<A HREF="/mod_mime.html#addlanguage">AddLanguage</A>,
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<A HREF="/mod_mime.html#addtype">AddType</A>, and
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<A HREF="core.html#options">Options</A>.
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<H2>Type maps</H2>
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian MaederA type map has the same format as RFC822 mail headers. It contains document
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maederdescriptions separated by blank lines, with lines beginning with a hash
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maedercharacter ('#') treated as comments. A document description consists of
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maederseveral header records; records may be continued on multiple lines if the
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maedercontinuation lines start with spaces. The leading space will be deleted
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maederand the lines concatenated. A header record consists of a keyword
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maedername, which always ends in a colon, followed by a value. Whitespace is allowed
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maederbetween the header name and value, and between the tokens of value.
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian MaederThe headers allowed are:
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<DL>
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<DT>Content-Encoding:
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<DD>The encoding of the file. Apache only recognizes encodings that are
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maederdefined by an <A HREF="mod_mime.html#addencoding">AddEncoding</A> directive.
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian MaederThis normally includes the encodings <CODE>x-compress</CODE> for compress'd
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maederfiles, and <CODE>x-gzip</CODE> for gzip'd files. The <CODE>x-</CODE> prefix
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maederis ignored for encoding comparisons.
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<DT>Content-Language:
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<DD>The language of the variant, as an Internet standard language tag
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder(RFC 1766). An example is <CODE>en</CODE>, meaning English.
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maeder<DT>Content-Length:
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<DD>The length of the file, in bytes. If this header is not present, then
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maederthe actual length of the file is used.
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maeder<DT>Content-Type:
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<DD>The MIME media type of the document, with optional parameters.
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian MaederParameters are separated from the media type and from one another by a
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maedersemi-colon, with a syntax of <CODE>name=value</CODE>. Common parameters
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maederinclude:
e7b0b439ffae08514ac1afc62186d9a87ec6bd59Christian Maeder<DL>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<DT>level
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<DD>an integer specifying the version of the media type.
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian MaederFor <CODE>text/html</CODE> this defaults to 2, otherwise 0.
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<DT>qs
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<DD>a floating-point number with a value in the range 0.0 to 1.0,
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maeder indicating the relative 'quality' of this variant
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder compared to the other available variants, independent of the client's
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder capabilities. For example, a jpeg file is usually of higher source
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder quality than an ascii file if it is attempting to represent a
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder photograph. However, if the resource being represented is ascii art,
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder then an ascii file would have a higher source quality than a jpeg file.
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maeder All qs values are therefore specific to a given resource.
38824a7dba4f7d82532afec67e0b594a5af5d76bChristian Maeder</DL>
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian MaederExample:
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<BLOCKQUOTE><CODE>Content-Type: image/jpeg; qs=0.8</CODE></BLOCKQUOTE>
e7b0b439ffae08514ac1afc62186d9a87ec6bd59Christian Maeder<DT>URI:
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maeder<DD>The path to the file containing this variant, relative to the map file.
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder</DL>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<H2>MultiViews</H2>
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian MaederA MultiViews search is enabled by the MultiViews
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<A HREF="core.html#options">Option</A>.
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian MaederIf the server receives a request for <CODE>/some/dir/foo</CODE> and
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maeder<CODE>/some/dir/foo</CODE> does <EM>not</EM> exist, then the server reads the
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maederdirectory looking for all files named <CODE>foo.*</CODE>, and effectively
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maederfakes up a type map which names all those files, assigning them the same media
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maedertypes and content-encodings it would have if the client had asked for
5b3e0bbb6a776c60dc14113435a44e7b13d2fa01Christian Maederone of them by name. It then chooses the best match to the client's
a1a48072301767054f2a9ff7ccf8974b0d6a6a28Christian Maederrequirements, and returns that document.<P>
<HR>
<H2><A NAME="cachenegotiateddocs">CacheNegotiatedDocs</A> directive</H2>
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> CacheNegotiatedDocs <EM>boolean</EM><BR>
<A
HREF="directive-dict.html#Default"
REL="Help"
><STRONG>Default:</STRONG></A> <CODE>CacheNegotiatedDocs off</CODE><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_negotiation<BR>
<A
HREF="directive-dict.html#Compatibility"
REL="Help"
><STRONG>Compatibility:</STRONG></A> CacheNegotiatedDocs is only available
in Apache 1.1 and later. The syntax changed in version 2.0.<P>
<P>If set, this directive allows content-negotiated documents to be
cached by proxy servers. This could mean that clients behind those
proxys could retrieve versions of the documents that are not the best
match for their abilities, but it will make caching more
efficient.
<P>This directive only applies to requests which come from HTTP/1.0 browsers.
HTTP/1.1 provides much better control over the caching of negotiated
documents, and this directive has no effect in responses to
HTTP/1.1 requests.
<P>Prior to version 2.0, CacheNegotiatedDocs did not take an argument;
it was turned on by the presence of the directive by itself.
<H2><A NAME="languagepriority">LanguagePriority</A> directive</H2>
<!--%plaintext &lt;?INDEX {\tt LanguagePriority} directive&gt; -->
<A
HREF="directive-dict.html#Syntax"
REL="Help"
><STRONG>Syntax:</STRONG></A> LanguagePriority <EM>MIME-lang MIME-lang...</EM><BR>
<A
HREF="directive-dict.html#Context"
REL="Help"
><STRONG>Context:</STRONG></A> server config, virtual host, directory, .htaccess<BR>
<A
HREF="directive-dict.html#Override"
REL="Help"
><STRONG>Override:</STRONG></A> FileInfo<BR>
<A
HREF="directive-dict.html#Status"
REL="Help"
><STRONG>Status:</STRONG></A> Base<BR>
<A
HREF="directive-dict.html#Module"
REL="Help"
><STRONG>Module:</STRONG></A> mod_negotiation<P>
The LanguagePriority 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 <EM>MIME-lang</EM> are in order of decreasing
preference. Example:
<BLOCKQUOTE><CODE>LanguagePriority en fr de</CODE></BLOCKQUOTE>
For a request for <CODE>foo.html</CODE>, where <CODE>foo.html.fr</CODE>
and <CODE>foo.html.de</CODE> both existed, but the browser did not express
a language preference, then <CODE>foo.html.fr</CODE> would be returned.<P>
<P>
Note that this directive only has an effect if a 'best' language
cannot be determined by any other means. Correctly implemented
HTTP/1.1 requests will mean this directive has no effect.
<P>
<STRONG>See also</STRONG>:
<A HREF="/mod_mime.html#defaultlanguage">DefaultLanguage</A> and
<A HREF="/mod_mime.html#addlanguage">AddLanguage</A>
<!--#include virtual="footer.html" -->
</BODY>
</HTML>