github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/content-negotiation.html.en (about)

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