mod_cache.xml revision 78f97ce162b66a0dbfd7af4dcd9984f162569b04
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard<!DOCTYPE modulesynopsis SYSTEM "/style/modulesynopsis.dtd">
e942c741056732f50da2074b36fe59805d370650slive<?xml-stylesheet type="text/xsl" href="/style/manual.en.xsl"?>
5f5d1b4cc970b7f06ff8ef6526128e9a27303d88nd<!-- $LastChangedRevision$ -->
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding Licensed to the Apache Software Foundation (ASF) under one or more
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding contributor license agreements. See the NOTICE file distributed with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding this work for additional information regarding copyright ownership.
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding The ASF licenses this file to You under the Apache License, Version 2.0
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding (the "License"); you may not use this file except in compliance with
db479b48bd4d75423ed4a45e15b75089d1a8ad72fielding the License. You may obtain a copy of the License at
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd Unless required by applicable law or agreed to in writing, software
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd distributed under the License is distributed on an "AS IS" BASIS,
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd See the License for the specific language governing permissions and
d5d794fc2f4cc9ca6d6da17cfa2cdcd8d244bacdnd limitations under the License.
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard<description>RFC 2616 compliant HTTP caching filter.</description>
b77f6f03c0b6bbc6ecd6e87358f568024733d680colm <note type="warning">This module should be used with care, as when the
b77f6f03c0b6bbc6ecd6e87358f568024733d680colm <directive module="mod_cache">CacheQuickHandler</directive> directive is
b77f6f03c0b6bbc6ecd6e87358f568024733d680colm in its default value of <strong>on</strong>, the <directive
b77f6f03c0b6bbc6ecd6e87358f568024733d680colm module="mod_authz_host">Allow</directive> and <directive
b77f6f03c0b6bbc6ecd6e87358f568024733d680colm module="mod_authz_host">Deny</directive> directives will be circumvented.
b77f6f03c0b6bbc6ecd6e87358f568024733d680colm You should not enable quick handler caching for any content to which you
b77f6f03c0b6bbc6ecd6e87358f568024733d680colm wish to limit access by client host name, address or environment
b77f6f03c0b6bbc6ecd6e87358f568024733d680colm variable.</note>
15f37a157fbbf107658ed82ec30c348a9b6e518end href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a> compliant
15f37a157fbbf107658ed82ec30c348a9b6e518end <strong>HTTP content caching filter</strong>, with support for the caching
1a2bc936a6b4aaf5713c98a230a449fd878d1f06takashi of content negotiated responses containing the Vary header.</p>
3ec4de296cf8eb31d8a59811b58720efafccf109patrikj <p>RFC 2616 compliant caching provides a mechanism to verify whether
97a9a944b5887e91042b019776c41d5dd74557aferikabele stale or expired content is still fresh, and can represent a significant
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj performance boost when the origin server supports <strong>conditional
3ec4de296cf8eb31d8a59811b58720efafccf109patrikj requests</strong> by honouring the
15f37a157fbbf107658ed82ec30c348a9b6e518end <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26">If-None-Match</a>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj HTTP request header. Content is only regenerated from scratch when the content
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj has changed, and not when the cached entry expires.</p>
b536777217c919cacb1a6f18eaeff001f3b3f13crbowen <p>As a filter, <module>mod_cache</module> can be placed in front of
88c775368960b64afcdfd93a812f466a109746baerikabele content originating from any handler, including <strong>flat
b536777217c919cacb1a6f18eaeff001f3b3f13crbowen files</strong> (served from a slow disk cached on a fast disk), the output
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard of a <strong>CGI script</strong> or <strong>dynamic content
88c775368960b64afcdfd93a812f466a109746baerikabele generator</strong>, or content <strong>proxied from another
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard <p>In the default configuration, <module>mod_cache</module> inserts the
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard caching filter as far forward as possible within the filter stack,
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard utilising the <strong>quick handler</strong> to bypass all per request
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard processing when returning content to the client. In this mode of
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard operation, <module>mod_cache</module> may be thought of as a caching
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard proxy server bolted to the front of the webserver, while running within
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard the webserver itself.</p>
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard <p>When the quick handler is switched off using the
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard <directive module="mod_cache">CacheQuickHandler</directive> directive,
88c775368960b64afcdfd93a812f466a109746baerikabele it becomes possible to insert the <strong>CACHE</strong> filter at a
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard point in the filter stack chosen by the administrator. This provides the
15f37a157fbbf107658ed82ec30c348a9b6e518end opportunity to cache content before that content is personalised by the
15f37a157fbbf107658ed82ec30c348a9b6e518end <module>mod_include</module> filter, or optionally compressed by the
15f37a157fbbf107658ed82ec30c348a9b6e518end <p>Under normal operation, <module>mod_cache</module> will respond to
15f37a157fbbf107658ed82ec30c348a9b6e518end and can be controlled by the
15f37a157fbbf107658ed82ec30c348a9b6e518end <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9">Cache-Control</a>
15f37a157fbbf107658ed82ec30c348a9b6e518end <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32">Pragma</a>
1a2bc936a6b4aaf5713c98a230a449fd878d1f06takashi headers sent from a client in a request, or from a
15f37a157fbbf107658ed82ec30c348a9b6e518end server within a response. Under exceptional circumstances,
15f37a157fbbf107658ed82ec30c348a9b6e518end <module>mod_cache</module> can be configured to override these headers
15f37a157fbbf107658ed82ec30c348a9b6e518end and force site specific behaviour, however such behaviour will be limited
15f37a157fbbf107658ed82ec30c348a9b6e518end to this cache only, and will not affect the operation of other caches
15f37a157fbbf107658ed82ec30c348a9b6e518end that may exist between the client and server, and as a result is not
15f37a157fbbf107658ed82ec30c348a9b6e518end recommended unless strictly necessary.</p>
15f37a157fbbf107658ed82ec30c348a9b6e518end <p>RFC 2616 allows for the cache to return stale data while the existing
15f37a157fbbf107658ed82ec30c348a9b6e518end stale entry is refreshed from the origin server, and this is supported
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm <directive module="mod_cache">CacheLock</directive> directive is suitably
15f37a157fbbf107658ed82ec30c348a9b6e518end configured. Such responses will contain a
15f37a157fbbf107658ed82ec30c348a9b6e518end <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.46">Warning</a>
15f37a157fbbf107658ed82ec30c348a9b6e518end HTTP header with a 110 response code. RFC 2616 also allows a cache to return
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard stale data when the attempt made to refresh the stale data returns an
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard error 500 or above, and this behaviour is supported by default by
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <module>mod_cache</module>. Such responses will contain a
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.46">Warning</a>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj HTTP header with a 111 response code.</p>
15f37a157fbbf107658ed82ec30c348a9b6e518end <p><module>mod_cache</module> requires the services of one or more
15f37a157fbbf107658ed82ec30c348a9b6e518end storage management modules. One storage management module is included in
15f37a157fbbf107658ed82ec30c348a9b6e518end the base Apache distribution:</p>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <dd>Implements a disk based storage manager. Headers and bodies are
15f37a157fbbf107658ed82ec30c348a9b6e518end stored separately on disk, in a directory structure derived from the
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj md5 hash of the cached URL. Multiple content negotiated responses can
1a2bc936a6b4aaf5713c98a230a449fd878d1f06takashi be stored concurrently, however the caching of partial content is not
15f37a157fbbf107658ed82ec30c348a9b6e518end supported by this module. The <program>htcacheclean</program> tool is
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj provided to list cached URLs, remove cached URLs, or to maintain the size
1a2bc936a6b4aaf5713c98a230a449fd878d1f06takashi of the disk cache within size and inode limits.</dd>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj <p>Further details, discussion, and examples, are provided in the
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj<seealso><a href="/caching.html">Caching Guide</a></seealso>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm<section id="related"><title>Related Modules and Directives</title>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm <modulelist>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm </modulelist>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm <directivelist>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm <directive module="mod_cache_disk">CacheRoot</directive>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm <directive module="mod_cache_disk">CacheDirLevels</directive>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm <directive module="mod_cache_disk">CacheDirLength</directive>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm <directive module="mod_cache_disk">CacheMinFileSize</directive>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm <directive module="mod_cache_disk">CacheMaxFileSize</directive>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm </directivelist>
89ebbccde2b87b469b9d6fdb606eeb943c12a824colm </related>
8d36abdf61277cb8ffcecc763c8a86c28f11f8e9covener<section id="sampleconf"><title>Sample Configuration</title>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard # Sample Cache Configuration<br />
15f37a157fbbf107658ed82ec30c348a9b6e518end LoadModule cache_disk_module modules/mod_cache_disk.so<br />
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard CacheRoot c:/cacheroot<br />
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard CacheEnable disk /<br />
15f37a157fbbf107658ed82ec30c348a9b6e518end CacheDirLevels 5<br />
15f37a157fbbf107658ed82ec30c348a9b6e518end CacheDirLength 3<br />
15f37a157fbbf107658ed82ec30c348a9b6e518end </IfModule> <br />
15f37a157fbbf107658ed82ec30c348a9b6e518end # When acting as a proxy, don't cache the list of security updates<br />
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard CacheDisable http://security.update.server/update-list/<br />
8d36abdf61277cb8ffcecc763c8a86c28f11f8e9covener </IfModule>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard<section id="thunderingherd"><title>Avoiding the Thundering Herd</title>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <p>When a cached entry becomes stale, <module>mod_cache</module> will submit
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard a conditional request to the backend, which is expected to confirm whether the
15f37a157fbbf107658ed82ec30c348a9b6e518end cached entry is still fresh, and send an updated entity if not.</p>
88c775368960b64afcdfd93a812f466a109746baerikabele <p>A small but finite amount of time exists between the time the cached entity
15f37a157fbbf107658ed82ec30c348a9b6e518end becomes stale, and the time the stale entity is fully refreshed. On a busy
15f37a157fbbf107658ed82ec30c348a9b6e518end server, a significant number of requests might arrive during this time, and
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard cause a <strong>thundering herd</strong> of requests to strike the backend
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard suddenly and unpredicably.</p>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj <p>To keep the thundering herd at bay, the <directive>CacheLock</directive>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj directive can be used to define a directory in which locks are created for
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj URLs <strong>in flight</strong>. The lock is used as a <strong>hint</strong>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj by other requests to either suppress an attempt to cache (someone else has
15f37a157fbbf107658ed82ec30c348a9b6e518end gone to fetch the entity), or to indicate that a stale entry is being refreshed
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard (stale content will be returned in the mean time).
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <p>When an entity is cached for the first time, a lock will be created for the
15f37a157fbbf107658ed82ec30c348a9b6e518end entity until the response has been fully cached. During the lifetime of the
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem lock, the cache will suppress the second and subsequent attempt to cache the
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem same entity. While this doesn't hold back the thundering herd, it does stop
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem the cache attempting to cache the same entity multiple times simultaneously.
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem <p>When an entity reaches its freshness lifetime and becomes stale, a lock
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem will be created for the entity until the response has either been confirmed as
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem still fresh, or replaced by the backend. During the lifetime of the lock, the
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem second and subsequent incoming request will cause stale data to be returned,
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem and the thundering herd is kept at bay.</p>
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem <p>Locks are used as a <strong>hint only</strong> to enable the cache to be
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem more gentle on backend servers, however the lock can be overridden if necessary.
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem If the client sends a request with a Cache-Control header forcing a reload, any
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem lock that may be present will be ignored, and the client's request will be
1b0dce86d7fc8a5aa4c89b05255be26e508c615crpluem honored immediately and the cached entry refreshed.</p>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <p>As a further safety mechanism, locks have a configurable maximum age.
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard Once this age has been reached, the lock is removed, and a new request is
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj given the opportunity to create a new lock. This maximum age can be set using
15f37a157fbbf107658ed82ec30c348a9b6e518end the <directive>CacheLockMaxAge</directive> directive, and defaults to 5
15f37a157fbbf107658ed82ec30c348a9b6e518end </section>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj # Enable the cache lock<br />
15f37a157fbbf107658ed82ec30c348a9b6e518end CacheLock on<br />
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard CacheLockMaxAge 5<br />
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard </IfModule>
15f37a157fbbf107658ed82ec30c348a9b6e518end<section id="finecontrol"><title>Fine Control with the CACHE Filter</title>
15f37a157fbbf107658ed82ec30c348a9b6e518end <p>Under the default mode of cache operation, the cache runs as a quick handler,
15f37a157fbbf107658ed82ec30c348a9b6e518end short circuiting the majority of server processing and offering the highest
15f37a157fbbf107658ed82ec30c348a9b6e518end cache performance available.</p>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <p>In this mode, the cache <strong>bolts onto</strong> the front of the server,
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj acting as if a free standing RFC 2616 caching proxy had been placed in front of
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj the server.</p>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj <p>While this mode offers the best performance, the administrator may find that
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj under certain circumstances they may want to perform further processing on the
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj request after the request is cached, such as to inject personalisation into the
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj cached page, or to apply authorisation restrictions to the content. Under these
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj circumstances, an administrator is often forced to place independent reverse
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj proxy servers either behind or in front of the caching server to achieve this.</p>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <p>To solve this problem the <directive module="mod_cache">CacheQuickHandler
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard </directive> directive can be set to <strong>off</strong>, and the server will
15f37a157fbbf107658ed82ec30c348a9b6e518end process all phases normally handled by a non-cached request, including the
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <strong>authentication and authorisation</strong> phases.</p>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <p>In addition, the administrator may optionally specify the <strong>precise point
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard within the filter chain</strong> where caching is to take place by adding the
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <strong>CACHE</strong> filter to the output filter chain.</p>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz <p>For example, to cache content before applying compression to the response,
15f37a157fbbf107658ed82ec30c348a9b6e518end place the <strong>CACHE</strong> filter before the <strong>DEFLATE</strong>
15f37a157fbbf107658ed82ec30c348a9b6e518end filter as in the example below:</p>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard # Cache content before optional compression<br />
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard CacheQuickHandler off<br />
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz AddOutputFilterByType CACHE;DEFLATE text/plain<br /><br />
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz <p>Another option is to have content cached before personalisation is applied
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz by <module>mod_include</module> (or another content processing filter). In this
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz example templates containing tags understood by
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz <module>mod_include</module> are cached before being parsed:</p>
15f37a157fbbf107658ed82ec30c348a9b6e518end # Cache content before mod_include and mod_deflate<br />
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard CacheQuickHandler off<br />
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz AddOutputFilterByType CACHE;INCLUDES;DEFLATE text/html<br /><br />
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz <p>You may place the <strong>CACHE</strong> filter anywhere you wish within the
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz filter chain. In this example, content is cached after being parsed by
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz <module>mod_include</module>, but before being processed by
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard # Cache content between mod_include and mod_deflate<br />
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard CacheQuickHandler off<br />
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem AddOutputFilterByType INCLUDES;CACHE;DEFLATE text/html<br /><br />
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem <note type="warning"><title>Warning:</title>If the location of the
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem <strong>CACHE</strong> filter in the filter chain is changed for any reason,
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem you may need to <strong>flush your cache</strong> to ensure that your data
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem served remains consistent. <module>mod_cache</module> is not in a position
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem to enforce this for you.</note>
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem<section id="status"><title>Cache Status and Logging</title>
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem <p>Once <module>mod_cache</module> has made a decision as to whether or not
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem an entity is to be served from cache, the detailed reason for the decision
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem is written to the subprocess environment within the request under the
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem <strong>cache-status</strong> key. This reason can be logged by the
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem <directive module="mod_log_config">LogFormat</directive> directive as
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem follows:</p>
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem LogFormat "%{cache-status}e ..."
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem <p>Based on the caching decision made, the reason is also written to the
fc3182e72cf0679cbf14a95213fbb9a98c3cf597rpluem subprocess environment under one the following three keys, as appropriate:</p>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj <dt>cache-hit</dt><dd>The response was served from cache.</dd>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj <dt>cache-revalidate</dt><dd>The response was stale and was successfully
15f37a157fbbf107658ed82ec30c348a9b6e518end revalidated, then served from cache.</dd>
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard <dt>cache-miss</dt><dd>The response was served from the upstream server.</dd>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <p>This makes it possible to support conditional logging of cached requests
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard as per the following example:</p>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj CustomLog cached-requests.log common env=cache-hit<br />
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj CustomLog uncached-requests.log common env=cache-miss<br />
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj CustomLog revalidated-requests.log common env=cache-revalidate<br />
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj<directivesynopsis>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj<description>Enable caching of specified URLs using a specified storage
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpjmanager</description>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj<syntax>CacheEnable <var>cache_type</var> <var>url-string</var></syntax>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj<contextlist><context>server config</context><context>virtual host</context>
62e52789bfc10a5fd0a433af77e77c8ebbbed6c2rederpj</contextlist>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <p>The <directive>CacheEnable</directive> directive instructs
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <module>mod_cache</module> to cache urls at or below
15f37a157fbbf107658ed82ec30c348a9b6e518end <var>url-string</var>. The cache storage manager is specified with the
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard <var>cache_type</var> argument. If the <directive>CacheEnable</directive>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard directive is placed inside a <directive type="section">Location</directive>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard directive, the <var>url-string</var> becomes optional.
1e5b300cc68389a18fe3762b1b980b0c86712ba1stoddard <module>mod_cache</module> to use the disk based storage manager
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz implemented by <module>mod_cache_disk</module>.</p>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz <p>In the event that the URL space overlaps between different
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz <directive>CacheEnable</directive> directives (as in the example below),
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz each possible storage manager will be run until the first one that
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz actually processes the request. The order in which the storage managers are
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz run is determined by the order of the <directive>CacheEnable</directive>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz directives in the configuration file.</p>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz <p>When acting as a forward proxy server, <var>url-string</var> can
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz also be used to specify remote sites and proxy protocols which
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz caching should be enabled for.</p>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz # Cache proxied url's<br />
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz # Cache FTP-proxied url's<br />
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz <p>A hostname starting with a <strong>"*"</strong> matches all hostnames with
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz that suffix. A hostname starting with <strong>"."</strong> matches all
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz hostnames containing the domain components that follow.</p>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz # Match www.apache.org, but not fooapache.org<br />
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz <p> The <code>no-cache</code> environment variable can be set to
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz disable caching on a finer grained set of resources in versions
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz 2.2.12 and later.</p>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz<seealso><a href="/env.html">Environment Variables in Apache</a></seealso>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz</directivesynopsis>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz<directivesynopsis>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz<description>Disable caching of specified URLs</description>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz<syntax>CacheDisable <var>url-string</var> | <var>on</var></syntax>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz<contextlist><context>server config</context><context>virtual host</context>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz</contextlist>
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz <p>The <directive>CacheDisable</directive> directive instructs
a80dd6ffd7a1484e7f45e4665689bdd84fc97153jerenkrantz <module>mod_cache</module> to <em>not</em> cache urls at or below
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz CacheDisable /local_files
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz <p>If used in a <directive type="section">Location</directive> directive,
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz the path needs to be specified below the Location, or if the word "on"
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz is used, caching for the whole location will be disabled.</p>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz <Location /foo><br />
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz CacheDisable on<br />
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz </Location><br />
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz <p> The <code>no-cache</code> environment variable can be set to
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz disable caching on a finer grained set of resources in versions
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz 2.2.12 and later.</p>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz<seealso><a href="/env.html">Environment Variables in Apache</a></seealso>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz</directivesynopsis>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz<directivesynopsis>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz<description>The maximum time in seconds to cache a document</description>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz<syntax>CacheMaxExpire <var>seconds</var></syntax>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz<default>CacheMaxExpire 86400 (one day)</default>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz</contextlist>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz <p>The <directive>CacheMaxExpire</directive> directive specifies the maximum number of
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz seconds for which cachable HTTP documents will be retained without checking the origin
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz server. Thus, documents will be out of date at most this number of seconds. This maximum
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz value is enforced even if an expiry date was supplied with the document.</p>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz CacheMaxExpire 604800
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz</directivesynopsis>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz<directivesynopsis>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz<description>The minimum time in seconds to cache a document</description>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz<syntax>CacheMinExpire <var>seconds</var></syntax>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz</contextlist>
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz <p>The <directive>CacheMinExpire</directive> directive specifies the minimum number of
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz seconds for which cachable HTTP documents will be retained without checking the origin
5c6cb72bfeee541644cea8177aefce1157571d3bjerenkrantz server. This is only used if no valid expire time was supplied with the document.</p>
721fdd19e2abef2e8dc46eb5c022ef14efe3367estoddard CacheMinExpire 3600
<description>The default duration to cache a document when no expiry date is specified.</description>