home *** CD-ROM | disk | FTP | other *** search
/ PC World 2003 November / PCWorld_2003-11_cd.bin / Komunik / apache / apache_2.0.47-win32-x86-no_ssl.msi / Data.Cab / F250499_contentnegotiation.html.en < prev    next >
Extensible Markup Language  |  2003-06-30  |  32KB  |  665 lines

  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
  4.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  5.               This file is generated from xml source: DO NOT EDIT
  6.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  7.       -->
  8. <title>Content Negotiation - Apache HTTP Server</title>
  9. <link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
  10. <link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
  11. <link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
  12. <link href="./images/favicon.ico" rel="shortcut icon" /></head>
  13. <body id="manual-page"><div id="page-header">
  14. <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p>
  15. <p class="apache">Apache HTTP Server Version 2.0</p>
  16. <img alt="" src="./images/feather.gif" /></div>
  17. <div class="up"><a href="./"><img title="<-" alt="<-" src="./images/left.gif" /></a></div>
  18. <div id="path">
  19. <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs-project/">Documentation</a> > <a href="./">Version 2.0</a></div><div id="page-content"><div id="preamble"><h1>Content Negotiation</h1>
  20. <div class="toplang">
  21. <p><span>Available Languages: </span><a href="./en/content-negotiation.html" title="English"> en </a> |
  22. <a href="./ja/content-negotiation.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
  23. <a href="./ko/content-negotiation.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
  24. </div>
  25.  
  26.  
  27.     <p>Apache's supports content negotiation as described in
  28.     the HTTP/1.1 specification. It can choose the best
  29.     representation of a resource based on the browser-supplied
  30.     preferences for media type, languages, character set and
  31.     encoding. It also implements a couple of features to give
  32.     more intelligent handling of requests from browsers that send
  33.     incomplete negotiation information.</p>
  34.  
  35.     <p>Content negotiation is provided by the
  36.     <code class="module"><a href="./mod/mod_negotiation.html">mod_negotiation</a></code> module.
  37.     which is compiled in by default.</p>
  38. </div>
  39. <div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#about">About Content Negotiation</a></li>
  40. <li><img alt="" src="./images/down.gif" /> <a href="#negotiation">Negotiation in Apache</a></li>
  41. <li><img alt="" src="./images/down.gif" /> <a href="#methods">The Negotiation Methods</a></li>
  42. <li><img alt="" src="./images/down.gif" /> <a href="#better">Fiddling with Quality
  43.     Values</a></li>
  44. <li><img alt="" src="./images/down.gif" /> <a href="#extensions">Extensions to Transparent Content
  45. Negotiation</a></li>
  46. <li><img alt="" src="./images/down.gif" /> <a href="#naming">Note on hyperlinks and naming conventions</a></li>
  47. <li><img alt="" src="./images/down.gif" /> <a href="#caching">Note on Caching</a></li>
  48. <li><img alt="" src="./images/down.gif" /> <a href="#more">More Information</a></li>
  49. </ul></div>
  50. <div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  51. <div class="section">
  52. <h2><a name="about" id="about">About Content Negotiation</a></h2>
  53.  
  54.     <p>A resource may be available in several different
  55.     representations. For example, it might be available in
  56.     different languages or different media types, or a combination.
  57.     One way of selecting the most appropriate choice is to give the
  58.     user an index page, and let them select. However it is often
  59.     possible for the server to choose automatically. This works
  60.     because browsers can send as part of each request information
  61.     about what representations they prefer. For example, a browser
  62.     could indicate that it would like to see information in French,
  63.     if possible, else English will do. Browsers indicate their
  64.     preferences by headers in the request. To request only French
  65.     representations, the browser would send</p>
  66.  
  67. <div class="example"><p><code>Accept-Language: fr</code></p></div>
  68.  
  69.     <p>Note that this preference will only be applied when there is
  70.     a choice of representations and they vary by language.</p>
  71.  
  72.     <p>As an example of a more complex request, this browser has
  73.     been configured to accept French and English, but prefer
  74.     French, and to accept various media types, preferring HTML over
  75.     plain text or other text types, and preferring GIF or JPEG over
  76.     other media types, but also allowing any other media type as a
  77.     last resort:</p>
  78.  
  79. <div class="example"><p><code>
  80.   Accept-Language: fr; q=1.0, en; q=0.5<br />
  81.   Accept: text/html; q=1.0, text/*; q=0.8, image/gif; q=0.6, image/jpeg; q=0.6, image/*; q=0.5, */*; q=0.1
  82. </code></p></div>
  83.  
  84.     <p>Apache supports 'server driven' content negotiation, as
  85.     defined in the HTTP/1.1 specification. It fully supports the
  86.     Accept, Accept-Language, Accept-Charset and Accept-Encoding
  87.     request headers. Apache also supports 'transparent'
  88.     content negotiation, which is an experimental negotiation
  89.     protocol defined in RFC 2295 and RFC 2296. It does not offer
  90.     support for 'feature negotiation' as defined in these RFCs. </p>
  91.  
  92.     <p>A <strong>resource</strong> is a conceptual entity
  93.     identified by a URI (RFC 2396). An HTTP server like Apache
  94.     provides access to <strong>representations</strong> of the
  95.     resource(s) within its namespace, with each representation in
  96.     the form of a sequence of bytes with a defined media type,
  97.     character set, encoding, etc. Each resource may be associated
  98.     with zero, one, or more than one representation at any given
  99.     time. If multiple representations are available, the resource
  100.     is referred to as <strong>negotiable</strong> and each of its
  101.     representations is termed a <strong>variant</strong>. The ways
  102.     in which the variants for a negotiable resource vary are called
  103.     the <strong>dimensions</strong> of negotiation.</p>
  104. </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  105. <div class="section">
  106. <h2><a name="negotiation" id="negotiation">Negotiation in Apache</a></h2>
  107.  
  108.     <p>In order to negotiate a resource, the server needs to be
  109.     given information about each of the variants. This is done in
  110.     one of two ways:</p>
  111.  
  112.     <ul>
  113.       <li>Using a type map (<em>i.e.</em>, a <code>*.var</code>
  114.       file) which names the files containing the variants
  115.       explicitly, or</li>
  116.  
  117.       <li>Using a 'MultiViews' search, where the server does an
  118.       implicit filename pattern match and chooses from among the
  119.       results.</li>
  120.     </ul>
  121.  
  122.    <h3><a name="type-map" id="type-map">Using a type-map file</a></h3>
  123.  
  124.     <p>A type map is a document which is associated with the
  125.     handler named <code>type-map</code> (or, for
  126.     backwards-compatibility with older Apache configurations, the
  127.     mime type <code>application/x-type-map</code>). Note that to
  128.     use this feature, you must have a handler set in the
  129.     configuration that defines a file suffix as
  130.     <code>type-map</code>; this is best done with a</p>
  131. <div class="example"><p><code>AddHandler type-map .var</code></p></div>
  132.     <p>in the server configuration file.</p>
  133.  
  134.     <p>Type map files should have the same name as the resource
  135.     which they are describing, and have an entry for each available
  136.     variant; these entries consist of contiguous HTTP-format header
  137.     lines. Entries for different variants are separated by blank
  138.     lines. Blank lines are illegal within an entry. It is
  139.     conventional to begin a map file with an entry for the combined
  140.     entity as a whole (although this is not required, and if
  141.     present will be ignored). An example map file is shown below.
  142.     This file would be named <code>foo.var</code>, as it describes
  143.     a resource named <code>foo</code>.</p>
  144.  
  145. <div class="example"><p><code>
  146.   URI: foo<br />
  147. <br />
  148.   URI: foo.en.html<br />
  149.   Content-type: text/html<br />
  150.   Content-language: en<br />
  151. <br />
  152.   URI: foo.fr.de.html<br />
  153.   Content-type: text/html;charset=iso-8859-2<br />
  154.   Content-language: fr, de<br />
  155. </code></p></div>
  156.     <p>Note also that a typemap file will take precedence over the
  157.     filename's extension, even when Multiviews is on. If the
  158.     variants have different source qualities, that may be indicated
  159.     by the "qs" parameter to the media type, as in this picture
  160.     (available as jpeg, gif, or ASCII-art): </p>
  161.  
  162. <div class="example"><p><code>
  163.   URI: foo<br />
  164. <br />
  165.   URI: foo.jpeg<br />
  166.   Content-type: image/jpeg; qs=0.8<br />
  167. <br />
  168.   URI: foo.gif<br />
  169.   Content-type: image/gif; qs=0.5<br />
  170. <br />
  171.   URI: foo.txt<br />
  172.   Content-type: text/plain; qs=0.01<br />
  173. </code></p></div>
  174.  
  175.     <p>qs values can vary in the range 0.000 to 1.000. Note that
  176.     any variant with a qs value of 0.000 will never be chosen.
  177.     Variants with no 'qs' parameter value are given a qs factor of
  178.     1.0. The qs parameter indicates the relative 'quality' of this
  179.     variant compared to the other available variants, independent
  180.     of the client's capabilities. For example, a jpeg file is
  181.     usually of higher source quality than an ascii file if it is
  182.     attempting to represent a photograph. However, if the resource
  183.     being represented is an original ascii art, then an ascii
  184.     representation would have a higher source quality than a jpeg
  185.     representation. A qs value is therefore specific to a given
  186.     variant depending on the nature of the resource it
  187.     represents.</p>
  188.  
  189.     <p>The full list of headers recognized is available in the <a href="mod/mod_negotiation.html#typemaps">mod_negotation
  190.     typemap</a> documentation.</p>
  191.  
  192.  
  193. <h3><a name="multiviews" id="multiviews">Multiviews</a></h3>
  194.  
  195.     <p><code>MultiViews</code> is a per-directory option, meaning it
  196.     can be set with an <code class="directive"><a href="./mod/core.html#options">Options</a></code>
  197.     directive within a <code class="directive"><a href="./mod/core.html#directory"><Directory></a></code>, <code class="directive"><a href="./mod/core.html#location"><Location></a></code> or <code class="directive"><a href="./mod/core.html#files"><Files></a></code> section in
  198.     <code>httpd.conf</code>, or (if <code class="directive"><a href="./mod/core.html#allowoverride">AllowOverride</a></code> is properly set) in
  199.     <code>.htaccess</code> files. Note that <code>Options All</code>
  200.     does not set <code>MultiViews</code>; you have to ask for it by
  201.     name.</p>
  202.  
  203.     <p>The effect of <code>MultiViews</code> is as follows: if the
  204.     server receives a request for <code>/some/dir/foo</code>, if
  205.     <code>/some/dir</code> has <code>MultiViews</code> enabled, and
  206.     <code>/some/dir/foo</code> does <em>not</em> exist, then the
  207.     server reads the directory looking for files named foo.*, and
  208.     effectively fakes up a type map which names all those files,
  209.     assigning them the same media types and content-encodings it
  210.     would have if the client had asked for one of them by name. It
  211.     then chooses the best match to the client's requirements.</p>
  212.  
  213.     <p><code>MultiViews</code> may also apply to searches for the file
  214.     named by the <code class="directive"><a href="./mod/mod_dir.html#directoryindex">DirectoryIndex</a></code> directive, if the
  215.     server is trying to index a directory. If the configuration files
  216.     specify</p>
  217. <div class="example"><p><code>DirectoryIndex index</code></p></div>
  218.     <p>then the server will arbitrate between <code>index.html</code>
  219.     and <code>index.html3</code> if both are present. If neither
  220.     are present, and <code>index.cgi</code> is there, the server
  221.     will run it.</p>
  222.  
  223.     <p>If one of the files found when reading the directory does not
  224.     have an extension recognized by <code>mod_mime</code> to designate
  225.     its Charset, Content-Type, Language, or Encoding, then the result
  226.     depends on the setting of the <code class="directive"><a href="./mod/mod_mime.html#multiviewsmatch">MultiViewsMatch</a></code> directive.  This
  227.     directive determines whether handlers, filters, and other
  228.     extension types can participate in MultiViews negotiation.</p>
  229.  
  230. </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  231. <div class="section">
  232. <h2><a name="methods" id="methods">The Negotiation Methods</a></h2>
  233.  
  234.     <p>After Apache has obtained a list of the variants for a given
  235.     resource, either from a type-map file or from the filenames in
  236.     the directory, it invokes one of two methods to decide on the
  237.     'best' variant to return, if any. It is not necessary to know
  238.     any of the details of how negotiation actually takes place in
  239.     order to use Apache's content negotiation features. However the
  240.     rest of this document explains the methods used for those
  241.     interested. </p>
  242.  
  243.     <p>There are two negotiation methods:</p>
  244.  
  245.     <ol>
  246.       <li><strong>Server driven negotiation with the Apache
  247.       algorithm</strong> is used in the normal case. The Apache
  248.       algorithm is explained in more detail below. When this
  249.       algorithm is used, Apache can sometimes 'fiddle' the quality
  250.       factor of a particular dimension to achieve a better result.
  251.       The ways Apache can fiddle quality factors is explained in
  252.       more detail below.</li>
  253.  
  254.       <li><strong>Transparent content negotiation</strong> is used
  255.       when the browser specifically requests this through the
  256.       mechanism defined in RFC 2295. This negotiation method gives
  257.       the browser full control over deciding on the 'best' variant,
  258.       the result is therefore dependent on the specific algorithms
  259.       used by the browser. As part of the transparent negotiation
  260.       process, the browser can ask Apache to run the 'remote
  261.       variant selection algorithm' defined in RFC 2296.</li>
  262.     </ol>
  263.  
  264. <h3><a name="dimensions" id="dimensions">Dimensions of Negotiation</a></h3>
  265.  
  266.     <table>
  267.       
  268.       <tr valign="top">
  269.         <th>Dimension</th>
  270.  
  271.         <th>Notes</th>
  272.       </tr>
  273.  
  274.       <tr valign="top">
  275.         <td>Media Type</td>
  276.  
  277.         <td>Browser indicates preferences with the Accept header
  278.         field. Each item can have an associated quality factor.
  279.         Variant description can also have a quality factor (the
  280.         "qs" parameter).</td>
  281.       </tr>
  282.  
  283.       <tr valign="top">
  284.         <td>Language</td>
  285.  
  286.         <td>Browser indicates preferences with the Accept-Language
  287.         header field. Each item can have a quality factor. Variants
  288.         can be associated with none, one or more than one
  289.         language.</td>
  290.       </tr>
  291.  
  292.       <tr valign="top">
  293.         <td>Encoding</td>
  294.  
  295.         <td>Browser indicates preference with the Accept-Encoding
  296.         header field. Each item can have a quality factor.</td>
  297.       </tr>
  298.  
  299.       <tr valign="top">
  300.         <td>Charset</td>
  301.  
  302.         <td>Browser indicates preference with the Accept-Charset
  303.         header field. Each item can have a quality factor. Variants
  304.         can indicate a charset as a parameter of the media
  305.         type.</td>
  306.       </tr>
  307.     </table>
  308.  
  309.  
  310. <h3><a name="algorithm" id="algorithm">Apache Negotiation Algorithm</a></h3>
  311.  
  312.     <p>Apache can use the following algorithm to select the 'best'
  313.     variant (if any) to return to the browser. This algorithm is
  314.     not further configurable. It operates as follows:</p>
  315.  
  316.     <ol>
  317.       <li>First, for each dimension of the negotiation, check the
  318.       appropriate <em>Accept*</em> header field and assign a
  319.       quality to each variant. If the <em>Accept*</em> header for
  320.       any dimension implies that this variant is not acceptable,
  321.       eliminate it. If no variants remain, go to step 4.</li>
  322.  
  323.       <li>
  324.         Select the 'best' variant by a process of elimination. Each
  325.         of the following tests is applied in order. Any variants
  326.         not selected at each test are eliminated. After each test,
  327.         if only one variant remains, select it as the best match
  328.         and proceed to step 3. If more than one variant remains,
  329.         move on to the next test. 
  330.  
  331.         <ol>
  332.           <li>Multiply the quality factor from the Accept header
  333.           with the quality-of-source factor for this variant's
  334.           media type, and select the variants with the highest
  335.           value.</li>
  336.  
  337.           <li>Select the variants with the highest language quality
  338.           factor.</li>
  339.  
  340.           <li>Select the variants with the best language match,
  341.           using either the order of languages in the
  342.           Accept-Language header (if present), or else the order of
  343.           languages in the <code>LanguagePriority</code> directive
  344.           (if present).</li>
  345.  
  346.           <li>Select the variants with the highest 'level' media
  347.           parameter (used to give the version of text/html media
  348.           types).</li>
  349.  
  350.           <li>Select variants with the best charset media
  351.           parameters, as given on the Accept-Charset header line.
  352.           Charset ISO-8859-1 is acceptable unless explicitly
  353.           excluded. Variants with a <code>text/*</code> media type
  354.           but not explicitly associated with a particular charset
  355.           are assumed to be in ISO-8859-1.</li>
  356.  
  357.           <li>Select those variants which have associated charset
  358.           media parameters that are <em>not</em> ISO-8859-1. If
  359.           there are no such variants, select all variants
  360.           instead.</li>
  361.  
  362.           <li>Select the variants with the best encoding. If there
  363.           are variants with an encoding that is acceptable to the
  364.           user-agent, select only these variants. Otherwise if
  365.           there is a mix of encoded and non-encoded variants,
  366.           select only the unencoded variants. If either all
  367.           variants are encoded or all variants are not encoded,
  368.           select all variants.</li>
  369.  
  370.           <li>Select the variants with the smallest content
  371.           length.</li>
  372.  
  373.           <li>Select the first variant of those remaining. This
  374.           will be either the first listed in the type-map file, or
  375.           when variants are read from the directory, the one whose
  376.           file name comes first when sorted using ASCII code
  377.           order.</li>
  378.         </ol>
  379.       </li>
  380.  
  381.       <li>The algorithm has now selected one 'best' variant, so
  382.       return it as the response. The HTTP response header Vary is
  383.       set to indicate the dimensions of negotiation (browsers and
  384.       caches can use this information when caching the resource).
  385.       End.</li>
  386.  
  387.       <li>To get here means no variant was selected (because none
  388.       are acceptable to the browser). Return a 406 status (meaning
  389.       "No acceptable representation") with a response body
  390.       consisting of an HTML document listing the available
  391.       variants. Also set the HTTP Vary header to indicate the
  392.       dimensions of variance.</li>
  393.     </ol>
  394.  
  395. </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  396. <div class="section">
  397. <h2><a name="better" id="better">Fiddling with Quality
  398.     Values</a></h2>
  399.  
  400.     <p>Apache sometimes changes the quality values from what would
  401.     be expected by a strict interpretation of the Apache
  402.     negotiation algorithm above. This is to get a better result
  403.     from the algorithm for browsers which do not send full or
  404.     accurate information. Some of the most popular browsers send
  405.     Accept header information which would otherwise result in the
  406.     selection of the wrong variant in many cases. If a browser
  407.     sends full and correct information these fiddles will not be
  408.     applied.</p>
  409.  
  410. <h3><a name="wildcards" id="wildcards">Media Types and Wildcards</a></h3>
  411.  
  412.     <p>The Accept: request header indicates preferences for media
  413.     types. It can also include 'wildcard' media types, such as
  414.     "image/*" or "*/*" where the * matches any string. So a request
  415.     including:</p>
  416.  
  417. <div class="example"><p><code>Accept: image/*, */*</code></p></div>
  418.  
  419.     <p>would indicate that any type starting "image/" is acceptable,
  420.     as is any other type.
  421.     Some browsers routinely send wildcards in addition to explicit
  422.     types they can handle. For example:</p>
  423.  
  424. <div class="example"><p><code>
  425.   Accept: text/html, text/plain, image/gif, image/jpeg, */*
  426. </code></p></div>
  427.     <p>The intention of this is to indicate that the explicitly listed
  428.     types are preferred, but if a different representation is
  429.     available, that is ok too.  Using explicit quality values,
  430.     what the browser really wants is something like:</p>
  431. <div class="example"><p><code>
  432.   Accept: text/html, text/plain, image/gif, image/jpeg, */*; q=0.01
  433. </code></p></div>
  434.     <p>The explicit types have no quality factor, so they default to a
  435.     preference of 1.0 (the highest). The wildcard */* is given a
  436.     low preference of 0.01, so other types will only be returned if
  437.     no variant matches an explicitly listed type.</p>
  438.  
  439.     <p>If the Accept: header contains <em>no</em> q factors at all,
  440.     Apache sets the q value of "*/*", if present, to 0.01 to
  441.     emulate the desired behavior. It also sets the q value of
  442.     wildcards of the format "type/*" to 0.02 (so these are
  443.     preferred over matches against "*/*". If any media type on the
  444.     Accept: header contains a q factor, these special values are
  445.     <em>not</em> applied, so requests from browsers which send the
  446.     explicit information to start with work as expected.</p>
  447.  
  448.  
  449. <h3><a name="exceptions" id="exceptions">Language Negotiation Exceptions</a></h3>
  450.  
  451.     <p>New in Apache 2.0, some exceptions have been added to the
  452.     negotiation algorithm to allow graceful fallback when language
  453.     negotiation fails to find a match.</p>
  454.  
  455.     <p>When a client requests a page on your server, but the server
  456.     cannot find a single page that matches the Accept-language sent by
  457.     the browser, the server will return either a "No Acceptable
  458.     Variant" or "Multiple Choices" response to the client.  To avoid
  459.     these error messages, it is possible to configure Apache to ignore
  460.     the Accept-language in these cases and provide a document that
  461.     does not explicitly match the client's request.  The <code class="directive"><a href="./mod/mod_negotiation.html#forcelanguagepriority">ForceLanguagePriority</a></code>
  462.     directive can be used to override one or both of these error
  463.     messages and substitute the servers judgement in the form of the 
  464.     <code class="directive"><a href="./mod/mod_negotiation.html#languagepriority">LanguagePriority</a></code>
  465.     directive.</p>
  466.  
  467.     <p>The server will also attempt to match language-subsets when no
  468.     other match can be found.  For example, if a client requests
  469.     documents with the language <code>en-GB</code> for British
  470.     English, the server is not normally allowed by the HTTP/1.1
  471.     standard to match that against a document that is marked as simply
  472.     <code>en</code>.  (Note that it is almost surely a configuration
  473.     error to include <code>en-GB</code> and not <code>en</code> in the
  474.     Accept-Language header, since it is very unlikely that a reader
  475.     understands British English, but doesn't understand English in
  476.     general.  Unfortunately, many current clients have default
  477.     configurations that resemble this.)  However, if no other language
  478.     match is possible and the server is about to return a "No
  479.     Acceptable Variants" error or fallback to the <code class="directive"><a href="./mod/mod_negotiation.html#languagepriority">LanguagePriority</a></code>, the server
  480.     will ignore the subset specification and match <code>en-GB</code>
  481.     against <code>en</code> documents.  Implicitly, Apache will add
  482.     the parent language to the client's acceptable language list with
  483.     a very low quality value.  But note that if the client requests
  484.     "en-GB; qs=0.9, fr; qs=0.8", and the server has documents
  485.     designated "en" and "fr", then the "fr" document will be returned.
  486.     This is necessary to maintain compliance with the HTTP/1.1
  487.     specification and to work effectively with properly configured
  488.     clients.</p>
  489.  
  490.     <p>In order to support advanced techniques (such as Cookies or
  491.     special URL-paths) to determine the user's preferred language,
  492.     since Apache 2.0.47 <code class="module"><a href="./mod/mod_negotiation.html">mod_negotiation</a></code> recognizes
  493.     the <a href="env.html">environment variable</a>
  494.     <code>prefer-language</code>. If it exists and contains an
  495.     appropriate language tag, <code class="module"><a href="./mod/mod_negotiation.html">mod_negotiation</a></code> will
  496.     try to select a matching variant. If there's no such variant,
  497.     the normal negotiation process applies.</p>
  498.  
  499.     <div class="example"><h3>Example</h3><p><code>
  500.       SetEnvIf Cookie "language=en" prefer-language=en<br />
  501.       SetEnvIf Cookie "language=fr" prefer-language=fr
  502.    </code></p></div>
  503.  
  504. </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  505. <div class="section">
  506. <h2><a name="extensions" id="extensions">Extensions to Transparent Content
  507. Negotiation</a></h2> 
  508.  
  509. <p>Apache extends the transparent content negotiation protocol (RFC
  510. 2295) as follows. A new <code>{encoding ..}</code> element is used in
  511. variant lists to label variants which are available with a specific
  512. content-encoding only. The implementation of the RVSA/1.0 algorithm
  513. (RFC 2296) is extended to recognize encoded variants in the list, and
  514. to use them as candidate variants whenever their encodings are
  515. acceptable according to the Accept-Encoding request header. The
  516. RVSA/1.0 implementation does not round computed quality factors to 5
  517. decimal places before choosing the best variant.</p>
  518. </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  519. <div class="section">
  520. <h2><a name="naming" id="naming">Note on hyperlinks and naming conventions</a></h2>
  521.  
  522.     <p>If you are using language negotiation you can choose between
  523.     different naming conventions, because files can have more than
  524.     one extension, and the order of the extensions is normally
  525.     irrelevant (see the <a href="mod/mod_mime.html#multipleext">mod_mime</a> documentation
  526.     for details).</p>
  527.  
  528.     <p>A typical file has a MIME-type extension (<em>e.g.</em>,
  529.     <code>html</code>), maybe an encoding extension (<em>e.g.</em>,
  530.     <code>gz</code>), and of course a language extension
  531.     (<em>e.g.</em>, <code>en</code>) when we have different
  532.     language variants of this file.</p>
  533.  
  534.     <p>Examples:</p>
  535.  
  536.     <ul>
  537.       <li>foo.en.html</li>
  538.  
  539.       <li>foo.html.en</li>
  540.  
  541.       <li>foo.en.html.gz</li>
  542.     </ul>
  543.  
  544.     <p>Here some more examples of filenames together with valid and
  545.     invalid hyperlinks:</p>
  546.  
  547.     <table class="bordered">
  548.       
  549.       <tr>
  550.         <th>Filename</th>
  551.  
  552.         <th>Valid hyperlink</th>
  553.  
  554.         <th>Invalid hyperlink</th>
  555.       </tr>
  556.  
  557.       <tr>
  558.         <td><em>foo.html.en</em></td>
  559.  
  560.         <td>foo<br />
  561.          foo.html</td>
  562.  
  563.         <td>-</td>
  564.       </tr>
  565.  
  566.       <tr>
  567.         <td><em>foo.en.html</em></td>
  568.  
  569.         <td>foo</td>
  570.  
  571.         <td>foo.html</td>
  572.       </tr>
  573.  
  574.       <tr>
  575.         <td><em>foo.html.en.gz</em></td>
  576.  
  577.         <td>foo<br />
  578.          foo.html</td>
  579.  
  580.         <td>foo.gz<br />
  581.          foo.html.gz</td>
  582.       </tr>
  583.  
  584.       <tr>
  585.         <td><em>foo.en.html.gz</em></td>
  586.  
  587.         <td>foo</td>
  588.  
  589.         <td>foo.html<br />
  590.          foo.html.gz<br />
  591.          foo.gz</td>
  592.       </tr>
  593.  
  594.       <tr>
  595.         <td><em>foo.gz.html.en</em></td>
  596.  
  597.         <td>foo<br />
  598.          foo.gz<br />
  599.          foo.gz.html</td>
  600.  
  601.         <td>foo.html</td>
  602.       </tr>
  603.  
  604.       <tr>
  605.         <td><em>foo.html.gz.en</em></td>
  606.  
  607.         <td>foo<br />
  608.          foo.html<br />
  609.          foo.html.gz</td>
  610.  
  611.         <td>foo.gz</td>
  612.       </tr>
  613.     </table>
  614.  
  615.     <p>Looking at the table above, you will notice that it is always
  616.     possible to use the name without any extensions in a hyperlink
  617.     (<em>e.g.</em>, <code>foo</code>). The advantage is that you
  618.     can hide the actual type of a document rsp. file and can change
  619.     it later, <em>e.g.</em>, from <code>html</code> to
  620.     <code>shtml</code> or <code>cgi</code> without changing any
  621.     hyperlink references.</p>
  622.  
  623.     <p>If you want to continue to use a MIME-type in your
  624.     hyperlinks (<em>e.g.</em> <code>foo.html</code>) the language
  625.     extension (including an encoding extension if there is one)
  626.     must be on the right hand side of the MIME-type extension
  627.     (<em>e.g.</em>, <code>foo.html.en</code>).</p>
  628. </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  629. <div class="section">
  630. <h2><a name="caching" id="caching">Note on Caching</a></h2>
  631.  
  632.     <p>When a cache stores a representation, it associates it with
  633.     the request URL. The next time that URL is requested, the cache
  634.     can use the stored representation. But, if the resource is
  635.     negotiable at the server, this might result in only the first
  636.     requested variant being cached and subsequent cache hits might
  637.     return the wrong response. To prevent this, Apache normally
  638.     marks all responses that are returned after content negotiation
  639.     as non-cacheable by HTTP/1.0 clients. Apache also supports the
  640.     HTTP/1.1 protocol features to allow caching of negotiated
  641.     responses.</p>
  642.  
  643.     <p>For requests which come from a HTTP/1.0 compliant client
  644.     (either a browser or a cache), the directive <code class="directive"><a href="./mod/mod_negotiation.html#cachenegotiateddocs">CacheNegotiatedDocs</a></code> can be
  645.     used to allow caching of responses which were subject to
  646.     negotiation. This directive can be given in the server config or
  647.     virtual host, and takes no arguments. It has no effect on requests
  648.     from HTTP/1.1 clients.</p>
  649. </div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
  650. <div class="section">
  651. <h2><a name="more" id="more">More Information</a></h2>
  652.  
  653.     <p>For more information about content negotiation, see Alan
  654.     J. Flavell's <a href="http://ppewww.ph.gla.ac.uk/~flavell/www/lang-neg.html">Language
  655.     Negotiation Notes</a>.  But note that this document may not be
  656.     updated to include changes in Apache 2.0.</p>
  657. </div></div>
  658. <div class="bottomlang">
  659. <p><span>Available Languages: </span><a href="./en/content-negotiation.html" title="English"> en </a> |
  660. <a href="./ja/content-negotiation.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
  661. <a href="./ko/content-negotiation.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
  662. </div><div id="footer">
  663. <p class="apache">Maintained by the <a href="http://httpd.apache.org/docs-project/">Apache HTTP Server Documentation Project</a></p>
  664. <p class="menu"><a href="./mod/">Modules</a> | <a href="./mod/directives.html">Directives</a> | <a href="./faq/">FAQ</a> | <a href="./glossary.html">Glossary</a> | <a href="./sitemap.html">Sitemap</a></p></div>
  665. </body></html>