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
8 <title>mod_cache - 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>
14 <div id="page-header">
15 <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>
16 <p class="apache">Apache HTTP Server Version 2.3</p>
17 <img alt="" src="../images/feather.gif" /></div>
18 <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
20 <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.3</a> > <a href="./">Modules</a></div>
21 <div id="page-content">
22 <div id="preamble"><h1>Apache Module mod_cache</h1>
24 <p><span>Available Languages: </span><a href="../en/mod/mod_cache.html" title="English"> en </a> |
25 <a href="../fr/mod/mod_cache.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
26 <a href="../ja/mod/mod_cache.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
27 <a href="../ko/mod/mod_cache.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
29 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>RFC 2616 compliant HTTP caching filter.</td></tr>
30 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
31 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>cache_module</td></tr>
32 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_cache.c</td></tr></table>
35 <div class="warning">This module should be used with care, as when the
36 <code class="directive"><a href="#cachequickhandler">CacheQuickHandler</a></code> directive is
37 in its default value of <strong>on</strong>, the <code class="directive"><a href="../mod/mod_authz_host.html#allow">Allow</a></code> and <code class="directive"><a href="../mod/mod_authz_host.html#deny">Deny</a></code> directives will be circumvented.
38 You should not enable quick handler caching for any content to which you
39 wish to limit access by client host name, address or environment
42 <p><code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> implements an <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a> compliant
43 <strong>HTTP content caching filter</strong>, with support for the caching
44 of content negotiated responses containing the Vary header.</p>
46 <p>RFC 2616 compliant caching provides a mechanism to verify whether
47 stale or expired content is still fresh, and can represent a significant
48 performance boost when the origin server supports <strong>conditional
49 requests</strong> by honouring the
50 <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26">If-None-Match</a>
51 HTTP request header. Content is only regenerated from scratch when the content
52 has changed, and not when the cached entry expires.</p>
54 <p>As a filter, <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> can be placed in front of
55 content originating from any handler, including <strong>flat
56 files</strong> (served from a slow disk cached on a fast disk), the output
57 of a <strong>CGI script</strong> or <strong>dynamic content
58 generator</strong>, or content <strong>proxied from another
61 <p>In the default configuration, <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> inserts the
62 caching filter as far forward as possible within the filter stack,
63 utilising the <strong>quick handler</strong> to bypass all per request
64 processing when returning content to the client. In this mode of
65 operation, <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> may be thought of as a caching
66 proxy server bolted to the front of the webserver, while running within
67 the webserver itself.</p>
69 <p>When the quick handler is switched off using the
70 <code class="directive"><a href="#cachequickhandler">CacheQuickHandler</a></code> directive,
71 it becomes possible to insert the <strong>CACHE</strong> filter at a
72 point in the filter stack chosen by the administrator. This provides the
73 opportunity to cache content before that content is personalised by the
74 <code class="module"><a href="../mod/mod_include.html">mod_include</a></code> filter, or optionally compressed by the
75 <code class="module"><a href="../mod/mod_deflate.html">mod_deflate</a></code> filter.</p>
77 <p>Under normal operation, <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> will respond to
78 and can be controlled by the
79 <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9">Cache-Control</a>
81 <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32">Pragma</a>
82 headers sent from a client in a request, or from a
83 server within a response. Under exceptional circumstances,
84 <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> can be configured to override these headers
85 and force site specific behaviour, however such behaviour will be limited
86 to this cache only, and will not affect the operation of other caches
87 that may exist between the client and server, and as a result is not
88 recommended unless strictly necessary.</p>
90 <p>RFC 2616 allows for the cache to return stale data while the existing
91 stale entry is refreshed from the origin server, and this is supported
92 by <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> when the
93 <code class="directive"><a href="#cachelock">CacheLock</a></code> directive is suitably
94 configured. Such responses will contain a
95 <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.46">Warning</a>
96 HTTP header with a 110 response code. RFC 2616 also allows a cache to return
97 stale data when the attempt made to refresh the stale data returns an
98 error 500 or above, and this behaviour is supported by default by
99 <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code>. Such responses will contain a
100 <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.46">Warning</a>
101 HTTP header with a 111 response code.</p>
103 <p><code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> requires the services of one or more
104 storage management modules. One storage management module is included in
105 the base Apache distribution:</p>
107 <dt><code class="module"><a href="../mod/mod_cache_disk.html">mod_cache_disk</a></code></dt>
108 <dd>Implements a disk based storage manager. Headers and bodies are
109 stored separately on disk, in a directory structure derived from the
110 md5 hash of the cached URL. Multiple content negotiated responses can
111 be stored concurrently, however the caching of partial content is not
112 supported by this module. The <code class="program"><a href="../programs/htcacheclean.html">htcacheclean</a></code> tool is
113 provided to list cached URLs, remove cached URLs, or to maintain the size
114 of the disk cache within size and inode limits.</dd>
117 <p>Further details, discussion, and examples, are provided in the
118 <a href="../caching.html">Caching Guide</a>.</p>
120 <div id="quickview"><h3 class="directives">Directives</h3>
122 <li><img alt="" src="../images/down.gif" /> <a href="#cachedefaultexpire">CacheDefaultExpire</a></li>
123 <li><img alt="" src="../images/down.gif" /> <a href="#cachedetailheader">CacheDetailHeader</a></li>
124 <li><img alt="" src="../images/down.gif" /> <a href="#cachedisable">CacheDisable</a></li>
125 <li><img alt="" src="../images/down.gif" /> <a href="#cacheenable">CacheEnable</a></li>
126 <li><img alt="" src="../images/down.gif" /> <a href="#cacheheader">CacheHeader</a></li>
127 <li><img alt="" src="../images/down.gif" /> <a href="#cacheignorecachecontrol">CacheIgnoreCacheControl</a></li>
128 <li><img alt="" src="../images/down.gif" /> <a href="#cacheignoreheaders">CacheIgnoreHeaders</a></li>
129 <li><img alt="" src="../images/down.gif" /> <a href="#cacheignorenolastmod">CacheIgnoreNoLastMod</a></li>
130 <li><img alt="" src="../images/down.gif" /> <a href="#cacheignorequerystring">CacheIgnoreQueryString</a></li>
131 <li><img alt="" src="../images/down.gif" /> <a href="#cacheignoreurlsessionidentifiers">CacheIgnoreURLSessionIdentifiers</a></li>
132 <li><img alt="" src="../images/down.gif" /> <a href="#cachekeybaseurl">CacheKeyBaseURL</a></li>
133 <li><img alt="" src="../images/down.gif" /> <a href="#cachelastmodifiedfactor">CacheLastModifiedFactor</a></li>
134 <li><img alt="" src="../images/down.gif" /> <a href="#cachelock">CacheLock</a></li>
135 <li><img alt="" src="../images/down.gif" /> <a href="#cachelockmaxage">CacheLockMaxAge</a></li>
136 <li><img alt="" src="../images/down.gif" /> <a href="#cachelockpath">CacheLockPath</a></li>
137 <li><img alt="" src="../images/down.gif" /> <a href="#cachemaxexpire">CacheMaxExpire</a></li>
138 <li><img alt="" src="../images/down.gif" /> <a href="#cacheminexpire">CacheMinExpire</a></li>
139 <li><img alt="" src="../images/down.gif" /> <a href="#cachequickhandler">CacheQuickHandler</a></li>
140 <li><img alt="" src="../images/down.gif" /> <a href="#cachestaleonerror">CacheStaleOnError</a></li>
141 <li><img alt="" src="../images/down.gif" /> <a href="#cachestoreexpired">CacheStoreExpired</a></li>
142 <li><img alt="" src="../images/down.gif" /> <a href="#cachestorenostore">CacheStoreNoStore</a></li>
143 <li><img alt="" src="../images/down.gif" /> <a href="#cachestoreprivate">CacheStorePrivate</a></li>
147 <li><img alt="" src="../images/down.gif" /> <a href="#related">Related Modules and Directives</a></li>
148 <li><img alt="" src="../images/down.gif" /> <a href="#sampleconf">Sample Configuration</a></li>
149 <li><img alt="" src="../images/down.gif" /> <a href="#thunderingherd">Avoiding the Thundering Herd</a></li>
150 <li><img alt="" src="../images/down.gif" /> <a href="#finecontrol">Fine Control with the CACHE Filter</a></li>
151 <li><img alt="" src="../images/down.gif" /> <a href="#status">Cache Status and Logging</a></li>
152 </ul><h3>See also</h3>
154 <li><a href="../caching.html">Caching Guide</a></li>
156 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
157 <div class="section">
158 <h2><a name="related" id="related">Related Modules and Directives</a></h2>
159 <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="../mod/mod_cache_disk.html">mod_cache_disk</a></code></li></ul></td><td><ul><li><code class="directive"><a href="../mod/mod_cache_disk.html#cacheroot">CacheRoot</a></code></li><li><code class="directive"><a href="../mod/mod_cache_disk.html#cachedirlevels">CacheDirLevels</a></code></li><li><code class="directive"><a href="../mod/mod_cache_disk.html#cachedirlength">CacheDirLength</a></code></li><li><code class="directive"><a href="../mod/mod_cache_disk.html#cacheminfilesize">CacheMinFileSize</a></code></li><li><code class="directive"><a href="../mod/mod_cache_disk.html#cachemaxfilesize">CacheMaxFileSize</a></code></li></ul></td></tr></table>
160 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
161 <div class="section">
162 <h2><a name="sampleconf" id="sampleconf">Sample Configuration</a></h2>
163 <div class="example"><h3>Sample httpd.conf</h3><p><code>
165 # Sample Cache Configuration<br />
167 LoadModule cache_module modules/mod_cache.so<br />
169 <IfModule mod_cache.c><br />
170 <span class="indent">
171 LoadModule cache_disk_module modules/mod_cache_disk.so<br />
172 <IfModule mod_cache_disk.c><br />
173 <span class="indent">
174 CacheRoot c:/cacheroot<br />
175 CacheEnable disk /<br />
176 CacheDirLevels 5<br />
177 CacheDirLength 3<br />
179 </IfModule> <br />
181 # When acting as a proxy, don't cache the list of security updates<br />
182 CacheDisable http://security.update.server/update-list/<br />
186 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
187 <div class="section">
188 <h2><a name="thunderingherd" id="thunderingherd">Avoiding the Thundering Herd</a></h2>
189 <p>When a cached entry becomes stale, <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> will submit
190 a conditional request to the backend, which is expected to confirm whether the
191 cached entry is still fresh, and send an updated entity if not.</p>
192 <p>A small but finite amount of time exists between the time the cached entity
193 becomes stale, and the time the stale entity is fully refreshed. On a busy
194 server, a significant number of requests might arrive during this time, and
195 cause a <strong>thundering herd</strong> of requests to strike the backend
196 suddenly and unpredicably.</p>
197 <p>To keep the thundering herd at bay, the <code class="directive">CacheLock</code>
198 directive can be used to define a directory in which locks are created for
199 URLs <strong>in flight</strong>. The lock is used as a <strong>hint</strong>
200 by other requests to either suppress an attempt to cache (someone else has
201 gone to fetch the entity), or to indicate that a stale entry is being refreshed
202 (stale content will be returned in the mean time).
204 <h3>Initial caching of an entry</h3>
206 <p>When an entity is cached for the first time, a lock will be created for the
207 entity until the response has been fully cached. During the lifetime of the
208 lock, the cache will suppress the second and subsequent attempt to cache the
209 same entity. While this doesn't hold back the thundering herd, it does stop
210 the cache attempting to cache the same entity multiple times simultaneously.
213 <h3>Refreshment of a stale entry</h3>
215 <p>When an entity reaches its freshness lifetime and becomes stale, a lock
216 will be created for the entity until the response has either been confirmed as
217 still fresh, or replaced by the backend. During the lifetime of the lock, the
218 second and subsequent incoming request will cause stale data to be returned,
219 and the thundering herd is kept at bay.</p>
221 <h3>Locks and Cache-Control: no-cache</h3>
223 <p>Locks are used as a <strong>hint only</strong> to enable the cache to be
224 more gentle on backend servers, however the lock can be overridden if necessary.
225 If the client sends a request with a Cache-Control header forcing a reload, any
226 lock that may be present will be ignored, and the client's request will be
227 honored immediately and the cached entry refreshed.</p>
228 <p>As a further safety mechanism, locks have a configurable maximum age.
229 Once this age has been reached, the lock is removed, and a new request is
230 given the opportunity to create a new lock. This maximum age can be set using
231 the <code class="directive">CacheLockMaxAge</code> directive, and defaults to 5
235 <h3>Example configuration</h3>
237 <div class="example"><h3>Enabling the cache lock</h3><p><code>
239 # Enable the cache lock<br />
241 <IfModule mod_cache.c><br />
242 <span class="indent">
244 CacheLockPath /tmp/mod_cache-lock<br />
245 CacheLockMaxAge 5<br />
250 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
251 <div class="section">
252 <h2><a name="finecontrol" id="finecontrol">Fine Control with the CACHE Filter</a></h2>
253 <p>Under the default mode of cache operation, the cache runs as a quick handler,
254 short circuiting the majority of server processing and offering the highest
255 cache performance available.</p>
257 <p>In this mode, the cache <strong>bolts onto</strong> the front of the server,
258 acting as if a free standing RFC 2616 caching proxy had been placed in front of
261 <p>While this mode offers the best performance, the administrator may find that
262 under certain circumstances they may want to perform further processing on the
263 request after the request is cached, such as to inject personalisation into the
264 cached page, or to apply authorisation restrictions to the content. Under these
265 circumstances, an administrator is often forced to place independent reverse
266 proxy servers either behind or in front of the caching server to achieve this.</p>
268 <p>To solve this problem the <code class="directive"><a href="#cachequickhandler ">CacheQuickHandler
269 </a></code> directive can be set to <strong>off</strong>, and the server will
270 process all phases normally handled by a non-cached request, including the
271 <strong>authentication and authorisation</strong> phases.</p>
273 <p>In addition, the administrator may optionally specify the <strong>precise point
274 within the filter chain</strong> where caching is to take place by adding the
275 <strong>CACHE</strong> filter to the output filter chain.</p>
277 <p>For example, to cache content before applying compression to the response,
278 place the <strong>CACHE</strong> filter before the <strong>DEFLATE</strong>
279 filter as in the example below:</p>
281 <div class="example"><p><code>
282 # Cache content before optional compression<br />
283 CacheQuickHandler off<br />
284 AddOutputFilterByType CACHE;DEFLATE text/plain<br /><br />
287 <p>Another option is to have content cached before personalisation is applied
288 by <code class="module"><a href="../mod/mod_include.html">mod_include</a></code> (or another content processing filter). In this
289 example templates containing tags understood by
290 <code class="module"><a href="../mod/mod_include.html">mod_include</a></code> are cached before being parsed:</p>
292 <div class="example"><p><code>
293 # Cache content before mod_include and mod_deflate<br />
294 CacheQuickHandler off<br />
295 AddOutputFilterByType CACHE;INCLUDES;DEFLATE text/html<br /><br />
298 <p>You may place the <strong>CACHE</strong> filter anywhere you wish within the
299 filter chain. In this example, content is cached after being parsed by
300 <code class="module"><a href="../mod/mod_include.html">mod_include</a></code>, but before being processed by
301 <code class="module"><a href="../mod/mod_deflate.html">mod_deflate</a></code>:</p>
303 <div class="example"><p><code>
304 # Cache content between mod_include and mod_deflate<br />
305 CacheQuickHandler off<br />
306 AddOutputFilterByType INCLUDES;CACHE;DEFLATE text/html<br /><br />
309 <div class="warning"><h3>Warning:</h3>If the location of the
310 <strong>CACHE</strong> filter in the filter chain is changed for any reason,
311 you may need to <strong>flush your cache</strong> to ensure that your data
312 served remains consistent. <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> is not in a position
313 to enforce this for you.</div>
315 </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
316 <div class="section">
317 <h2><a name="status" id="status">Cache Status and Logging</a></h2>
318 <p>Once <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> has made a decision as to whether or not
319 an entity is to be served from cache, the detailed reason for the decision
320 is written to the subprocess environment within the request under the
321 <strong>cache-status</strong> key. This reason can be logged by the
322 <code class="directive"><a href="../mod/mod_log_config.html#logformat">LogFormat</a></code> directive as
325 <div class="example"><p><code>
326 LogFormat "%{cache-status}e ..."
329 <p>Based on the caching decision made, the reason is also written to the
330 subprocess environment under one the following four keys, as appropriate:</p>
333 <dt>cache-hit</dt><dd>The response was served from cache.</dd>
334 <dt>cache-revalidate</dt><dd>The response was stale and was successfully
335 revalidated, then served from cache.</dd>
336 <dt>cache-miss</dt><dd>The response was served from the upstream server.</dd>
337 <dt>cache-invalidate</dt><dd>The cached entity was invalidated by a request
338 method other than GET or HEAD.</dd>
341 <p>This makes it possible to support conditional logging of cached requests
342 as per the following example:</p>
344 <div class="example"><p><code>
345 CustomLog cached-requests.log common env=cache-hit<br />
346 CustomLog uncached-requests.log common env=cache-miss<br />
347 CustomLog revalidated-requests.log common env=cache-revalidate<br />
348 CustomLog invalidated-requests.log common env=cache-invalidate<br />
351 <p>For module authors, a hook called <var>cache_status</var> is available,
352 allowing modules to respond to the caching outcomes above in customised
355 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
356 <div class="directive-section"><h2><a name="CacheDefaultExpire" id="CacheDefaultExpire">CacheDefaultExpire</a> <a name="cachedefaultexpire" id="cachedefaultexpire">Directive</a></h2>
357 <table class="directive">
358 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The default duration to cache a document when no expiry date is specified.</td></tr>
359 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheDefaultExpire <var>seconds</var></code></td></tr>
360 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheDefaultExpire 3600 (one hour)</code></td></tr>
361 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
362 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
363 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
365 <p>The <code class="directive">CacheDefaultExpire</code> directive specifies a default time,
366 in seconds, to cache a document if neither an expiry date nor last-modified date are provided
367 with the document. The value specified with the <code class="directive">CacheMaxExpire</code>
368 directive does <em>not</em> override this setting.</p>
370 <div class="example"><p><code>
371 CacheDefaultExpire 86400
375 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
376 <div class="directive-section"><h2><a name="CacheDetailHeader" id="CacheDetailHeader">CacheDetailHeader</a> <a name="cachedetailheader" id="cachedetailheader">Directive</a></h2>
377 <table class="directive">
378 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Add an X-Cache-Detail header to the response.</td></tr>
379 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheDetailHeader <var>on|off</var></code></td></tr>
380 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheDetailHeader off</code></td></tr>
381 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
382 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
383 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
384 <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.3.9 and later</td></tr>
386 <p>When the <code class="directive"><a href="#cachedetailheader">CacheDetailHeader</a></code> directive
387 is switched on, an <strong>X-Cache-Detail</strong> header will be added to the response
388 containing the detailed reason for a particular caching decision.</p>
390 <p>It can be useful during development of cached RESTful services to have additional
391 information about the caching decision written to the response headers, so as to
392 confirm whether <code>Cache-Control</code> and other headers have been correctly
393 used by the service and client.</p>
395 <p>If the normal handler is used, this directive may appear within a
396 <code class="directive"><a href="../mod/core.html#<directory>"><Directory></a></code> or
397 <code class="directive"><a href="../mod/core.html#<location>"><Location></a></code> directive. If the quick handler
398 is used, this directive must appear within a server or virtual host context, otherwise
399 the setting will be ignored.</p>
401 <div class="example"><p><code>
402 # Enable the X-Cache-Detail header<br />
403 CacheDetailHeader on<br />
406 <div class="example"><p><code>
407 X-Cache-Detail: "conditional cache hit: entity refreshed" from localhost<br />
412 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
413 <div class="directive-section"><h2><a name="CacheDisable" id="CacheDisable">CacheDisable</a> <a name="cachedisable" id="cachedisable">Directive</a></h2>
414 <table class="directive">
415 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Disable caching of specified URLs</td></tr>
416 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheDisable <var>url-string</var> | <var>on</var></code></td></tr>
417 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
418 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
419 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
421 <p>The <code class="directive">CacheDisable</code> directive instructs
422 <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> to <em>not</em> cache urls at or below
423 <var>url-string</var>.</p>
425 <div class="example"><h3>Example</h3><p><code>
426 CacheDisable /local_files
429 <p>If used in a <code class="directive"><Location></code> directive,
430 the path needs to be specified below the Location, or if the word "on"
431 is used, caching for the whole location will be disabled.</p>
433 <div class="example"><h3>Example</h3><p><code>
434 <Location /foo><br />
435 CacheDisable on<br />
436 </Location><br />
439 <p> The <code>no-cache</code> environment variable can be set to
440 disable caching on a finer grained set of resources in versions
441 2.2.12 and later.</p>
446 <li><a href="../env.html">Environment Variables in Apache</a></li>
449 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
450 <div class="directive-section"><h2><a name="CacheEnable" id="CacheEnable">CacheEnable</a> <a name="cacheenable" id="cacheenable">Directive</a></h2>
451 <table class="directive">
452 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enable caching of specified URLs using a specified storage
454 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheEnable <var>cache_type</var> <var>url-string</var></code></td></tr>
455 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
456 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
457 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
459 <p>The <code class="directive">CacheEnable</code> directive instructs
460 <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> to cache urls at or below
461 <var>url-string</var>. The cache storage manager is specified with the
462 <var>cache_type</var> argument. If the <code class="directive">CacheEnable</code>
463 directive is placed inside a <code class="directive"><Location></code>
464 directive, the <var>url-string</var> becomes optional.
465 <var>cache_type</var> <code>disk</code> instructs
466 <code class="module"><a href="../mod/mod_cache.html">mod_cache</a></code> to use the disk based storage manager
467 implemented by <code class="module"><a href="../mod/mod_cache_disk.html">mod_cache_disk</a></code>.</p>
468 <p>In the event that the URL space overlaps between different
469 <code class="directive">CacheEnable</code> directives (as in the example below),
470 each possible storage manager will be run until the first one that
471 actually processes the request. The order in which the storage managers are
472 run is determined by the order of the <code class="directive">CacheEnable</code>
473 directives in the configuration file.</p>
475 <p>When acting as a forward proxy server, <var>url-string</var> can
476 also be used to specify remote sites and proxy protocols which
477 caching should be enabled for.</p>
479 <div class="example"><p><code>
480 # Cache proxied url's<br />
481 CacheEnable disk /<br /><br />
482 # Cache FTP-proxied url's<br />
483 CacheEnable disk ftp://<br /><br />
484 # Cache content from www.example.org<br />
485 CacheEnable disk http://www.example.org/<br />
488 <p>A hostname starting with a <strong>"*"</strong> matches all hostnames with
489 that suffix. A hostname starting with <strong>"."</strong> matches all
490 hostnames containing the domain components that follow.</p>
492 <div class="example"><p><code>
493 # Match www.example.org, and fooexample.org<br />
494 CacheEnable disk http://*example.org/<br />
495 # Match www.example.org, but not fooexample.org<br />
496 CacheEnable disk http://.example.org/<br />
499 <p> The <code>no-cache</code> environment variable can be set to
500 disable caching on a finer grained set of resources in versions
501 2.2.12 and later.</p>
506 <li><a href="../env.html">Environment Variables in Apache</a></li>
509 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
510 <div class="directive-section"><h2><a name="CacheHeader" id="CacheHeader">CacheHeader</a> <a name="cacheheader" id="cacheheader">Directive</a></h2>
511 <table class="directive">
512 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Add an X-Cache header to the response.</td></tr>
513 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheHeader <var>on|off</var></code></td></tr>
514 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheHeader off</code></td></tr>
515 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
516 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
517 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
518 <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.3.9 and later</td></tr>
520 <p>When the <code class="directive"><a href="#cacheheader">CacheHeader</a></code> directive
521 is switched on, an <strong>X-Cache</strong> header will be added to the response
522 with the cache status of this response. If the normal handler is used, this
523 directive may appear within a <code class="directive"><a href="../mod/core.html#<directory>"><Directory></a></code>
524 or <code class="directive"><a href="../mod/core.html#<location>"><Location></a></code> directive. If the quick
525 handler is used, this directive must appear within a server or virtual host
526 context, otherwise the setting will be ignored.</p>
529 <dt><strong>HIT</strong></dt><dd>The entity was fresh, and was served from
531 <dt><strong>REVALIDATE</strong></dt><dd>The entity was stale, was successfully
532 revalidated and was served from cache.</dd>
533 <dt><strong>MISS</strong></dt><dd>The entity was fetched from the upstream
534 server and was not served from cache.</dd>
537 <div class="example"><p><code>
538 # Enable the X-Cache header<br />
542 <div class="example"><p><code>
543 X-Cache: HIT from localhost<br />
548 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
549 <div class="directive-section"><h2><a name="CacheIgnoreCacheControl" id="CacheIgnoreCacheControl">CacheIgnoreCacheControl</a> <a name="cacheignorecachecontrol" id="cacheignorecachecontrol">Directive</a></h2>
550 <table class="directive">
551 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Ignore request to not serve cached content to client</td></tr>
552 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheIgnoreCacheControl On|Off</code></td></tr>
553 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheIgnoreCacheControl Off</code></td></tr>
554 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
555 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
556 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
558 <p>Ordinarily, requests containing a Cache-Control: no-cache or
559 Pragma: no-cache header value will not be served from the cache. The
560 <code class="directive">CacheIgnoreCacheControl</code> directive allows this
561 behavior to be overridden. <code class="directive">CacheIgnoreCacheControl On</code>
562 tells the server to attempt to serve the resource from the cache even
563 if the request contains no-cache header values. Resources requiring
564 authorization will <em>never</em> be cached.</p>
566 <div class="example"><p><code>
567 CacheIgnoreCacheControl On
570 <div class="warning"><h3>Warning:</h3>
571 This directive will allow serving from the cache even if the client has
572 requested that the document not be served from the cache. This might
573 result in stale content being served.
578 <li><code class="directive"><a href="#cachestoreprivate">CacheStorePrivate</a></code></li>
579 <li><code class="directive"><a href="#cachestorenostore">CacheStoreNoStore</a></code></li>
582 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
583 <div class="directive-section"><h2><a name="CacheIgnoreHeaders" id="CacheIgnoreHeaders">CacheIgnoreHeaders</a> <a name="cacheignoreheaders" id="cacheignoreheaders">Directive</a></h2>
584 <table class="directive">
585 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Do not store the given HTTP header(s) in the cache.
587 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheIgnoreHeaders <var>header-string</var> [<var>header-string</var>] ...</code></td></tr>
588 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheIgnoreHeaders None</code></td></tr>
589 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
590 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
591 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
593 <p>According to RFC 2616, hop-by-hop HTTP headers are not stored in
594 the cache. The following HTTP headers are hop-by-hop headers and thus
595 do not get stored in the cache in <em>any</em> case regardless of the
596 setting of <code class="directive">CacheIgnoreHeaders</code>:</p>
599 <li><code>Connection</code></li>
600 <li><code>Keep-Alive</code></li>
601 <li><code>Proxy-Authenticate</code></li>
602 <li><code>Proxy-Authorization</code></li>
603 <li><code>TE</code></li>
604 <li><code>Trailers</code></li>
605 <li><code>Transfer-Encoding</code></li>
606 <li><code>Upgrade</code></li>
609 <p><code class="directive">CacheIgnoreHeaders</code> specifies additional HTTP
610 headers that should not to be stored in the cache. For example, it makes
611 sense in some cases to prevent cookies from being stored in the cache.</p>
613 <p><code class="directive">CacheIgnoreHeaders</code> takes a space separated list
614 of HTTP headers that should not be stored in the cache. If only hop-by-hop
615 headers not should be stored in the cache (the RFC 2616 compliant
616 behaviour), <code class="directive">CacheIgnoreHeaders</code> can be set to
617 <code>None</code>.</p>
619 <div class="example"><h3>Example 1</h3><p><code>
620 CacheIgnoreHeaders Set-Cookie
623 <div class="example"><h3>Example 2</h3><p><code>
624 CacheIgnoreHeaders None
627 <div class="warning"><h3>Warning:</h3>
628 If headers like <code>Expires</code> which are needed for proper cache
629 management are not stored due to a
630 <code class="directive">CacheIgnoreHeaders</code> setting, the behaviour of
631 mod_cache is undefined.
635 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
636 <div class="directive-section"><h2><a name="CacheIgnoreNoLastMod" id="CacheIgnoreNoLastMod">CacheIgnoreNoLastMod</a> <a name="cacheignorenolastmod" id="cacheignorenolastmod">Directive</a></h2>
637 <table class="directive">
638 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Ignore the fact that a response has no Last Modified
640 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheIgnoreNoLastMod On|Off</code></td></tr>
641 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheIgnoreNoLastMod Off</code></td></tr>
642 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
643 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
644 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
646 <p>Ordinarily, documents without a last-modified date are not cached.
647 Under some circumstances the last-modified date is removed (during
648 <code class="module"><a href="../mod/mod_include.html">mod_include</a></code> processing for example) or not provided
649 at all. The <code class="directive">CacheIgnoreNoLastMod</code> directive
650 provides a way to specify that documents without last-modified dates
651 should be considered for caching, even without a last-modified date.
652 If neither a last-modified date nor an expiry date are provided with
653 the document then the value specified by the
654 <code class="directive">CacheDefaultExpire</code> directive will be used to
655 generate an expiration date.</p>
657 <div class="example"><p><code>
658 CacheIgnoreNoLastMod On
662 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
663 <div class="directive-section"><h2><a name="CacheIgnoreQueryString" id="CacheIgnoreQueryString">CacheIgnoreQueryString</a> <a name="cacheignorequerystring" id="cacheignorequerystring">Directive</a></h2>
664 <table class="directive">
665 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Ignore query string when caching</td></tr>
666 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheIgnoreQueryString On|Off</code></td></tr>
667 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheIgnoreQueryString Off</code></td></tr>
668 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
669 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
670 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
672 <p>Ordinarily, requests with query string parameters are cached separately
673 for each unique query string. This is according to RFC 2616/13.9 done only
674 if an expiration time is specified. The
675 <code class="directive">CacheIgnoreQueryString</code> directive tells the cache to
676 cache requests even if no expiration time is specified, and to reply with
677 a cached reply even if the query string differs. From a caching point of
678 view the request is treated as if having no query string when this
679 directive is enabled.</p>
681 <div class="example"><p><code>
682 CacheIgnoreQueryString On
687 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
688 <div class="directive-section"><h2><a name="CacheIgnoreURLSessionIdentifiers" id="CacheIgnoreURLSessionIdentifiers">CacheIgnoreURLSessionIdentifiers</a> <a name="cacheignoreurlsessionidentifiers" id="cacheignoreurlsessionidentifiers">Directive</a></h2>
689 <table class="directive">
690 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Ignore defined session identifiers encoded in the URL when caching
692 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheIgnoreURLSessionIdentifiers <var>identifier</var> [<var>identifier</var>] ...</code></td></tr>
693 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheIgnoreURLSessionIdentifiers None</code></td></tr>
694 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
695 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
696 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
698 <p>Sometimes applications encode the session identifier into the URL like in the following
702 <li><code>/someapplication/image.gif;jsessionid=123456789</code></li>
703 <li><code>/someapplication/image.gif?PHPSESSIONID=12345678</code></li>
705 <p>This causes cachable resources to be stored separately for each session, which
706 is often not desired. <code class="directive">CacheIgnoreURLSessionIdentifiers</code> lets
707 define a list of identifiers that are removed from the key that is used to identify
708 an entity in the cache, such that cachable resources are not stored separately for
711 <p><code>CacheIgnoreURLSessionIdentifiers None</code> clears the list of ignored
712 identifiers. Otherwise, each identifier is added to the list.</p>
714 <div class="example"><h3>Example 1</h3><p><code>
715 CacheIgnoreURLSessionIdentifiers jsessionid
718 <div class="example"><h3>Example 2</h3><p><code>
719 CacheIgnoreURLSessionIdentifiers None
724 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
725 <div class="directive-section"><h2><a name="CacheKeyBaseURL" id="CacheKeyBaseURL">CacheKeyBaseURL</a> <a name="cachekeybaseurl" id="cachekeybaseurl">Directive</a></h2>
726 <table class="directive">
727 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Override the base URL of reverse proxied cache keys.</td></tr>
728 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheKeyBaseURL <var>URL</var></code></td></tr>
729 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheKeyBaseURL http://example.com</code></td></tr>
730 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
731 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
732 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
733 <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.3.9 and later</td></tr>
735 <p>When the <code class="directive"><a href="#cachekeybaseurl">CacheKeyBaseURL</a></code> directive
736 is specified, the URL provided will be used as the base URL to calculate
737 the URL of the cache keys in the reverse proxy configuration. When not specified,
738 the scheme, hostname and port of the current virtual host is used to construct
739 the cache key. When a cluster of machines is present, and all cached entries
740 should be cached beneath the same cache key, a new base URL can be specified
741 with this directive.</p>
743 <div class="example"><p><code>
744 # Override the base URL of the cache key.<br />
745 CacheKeyBaseURL http://www.example.com/<br />
748 <div class="warning">Take care when setting this directive. If two separate virtual
749 hosts are accidentally given the same base URL, entries from one virtual host
750 will be served to the other.</div>
754 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
755 <div class="directive-section"><h2><a name="CacheLastModifiedFactor" id="CacheLastModifiedFactor">CacheLastModifiedFactor</a> <a name="cachelastmodifiedfactor" id="cachelastmodifiedfactor">Directive</a></h2>
756 <table class="directive">
757 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The factor used to compute an expiry date based on the
758 LastModified date.</td></tr>
759 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheLastModifiedFactor <var>float</var></code></td></tr>
760 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheLastModifiedFactor 0.1</code></td></tr>
761 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
762 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
763 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
765 <p>In the event that a document does not provide an expiry date but does
766 provide a last-modified date, an expiry date can be calculated based on
767 the time since the document was last modified. The
768 <code class="directive">CacheLastModifiedFactor</code> directive specifies a
769 <var>factor</var> to be used in the generation of this expiry date
770 according to the following formula:
772 <code>expiry-period = time-since-last-modified-date * <var>factor</var>
773 expiry-date = current-date + expiry-period</code>
775 For example, if the document was last modified 10 hours ago, and
776 <var>factor</var> is 0.1 then the expiry-period will be set to
777 10*0.1 = 1 hour. If the current time was 3:00pm then the computed
778 expiry-date would be 3:00pm + 1hour = 4:00pm.
780 If the expiry-period would be longer than that set by
781 <code class="directive">CacheMaxExpire</code>, then the latter takes
784 <div class="example"><p><code>
785 CacheLastModifiedFactor 0.5
789 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
790 <div class="directive-section"><h2><a name="CacheLock" id="CacheLock">CacheLock</a> <a name="cachelock" id="cachelock">Directive</a></h2>
791 <table class="directive">
792 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enable the thundering herd lock.</td></tr>
793 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheLock <var>on|off</var></code></td></tr>
794 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheLock off</code></td></tr>
795 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
796 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
797 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
798 <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.2.15 and later</td></tr>
800 <p>The <code class="directive">CacheLock</code> directive enables the thundering herd lock
801 for the given URL space.</p>
803 <p>In a minimal configuration the following directive is all that is needed to
804 enable the thundering herd lock in the default system temp directory.</p>
806 <div class="example"><p><code>
807 # Enable cache lock<br />
808 CacheLock on<br /><br />
813 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
814 <div class="directive-section"><h2><a name="CacheLockMaxAge" id="CacheLockMaxAge">CacheLockMaxAge</a> <a name="cachelockmaxage" id="cachelockmaxage">Directive</a></h2>
815 <table class="directive">
816 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Set the maximum possible age of a cache lock.</td></tr>
817 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheLockMaxAge <var>integer</var></code></td></tr>
818 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheLockMaxAge 5</code></td></tr>
819 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
820 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
821 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
823 <p>The <code class="directive">CacheLockMaxAge</code> directive specifies the maximum
824 age of any cache lock.</p>
826 <p>A lock older than this value in seconds will be ignored, and the next
827 incoming request will be given the opportunity to re-establish the lock.
828 This mechanism prevents a slow client taking an excessively long time to refresh
833 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
834 <div class="directive-section"><h2><a name="CacheLockPath" id="CacheLockPath">CacheLockPath</a> <a name="cachelockpath" id="cachelockpath">Directive</a></h2>
835 <table class="directive">
836 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Set the lock path directory.</td></tr>
837 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheLockPath <var>directory</var></code></td></tr>
838 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheLockPath /tmp/mod_cache-lock</code></td></tr>
839 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
840 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
841 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
843 <p>The <code class="directive">CacheLockPath</code> directive allows you to specify the
844 directory in which the locks are created. By default, the system's temporary
845 folder is used. Locks consist of empty files that only exist for stale URLs
846 in flight, so is significantly less resource intensive than the traditional
851 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
852 <div class="directive-section"><h2><a name="CacheMaxExpire" id="CacheMaxExpire">CacheMaxExpire</a> <a name="cachemaxexpire" id="cachemaxexpire">Directive</a></h2>
853 <table class="directive">
854 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The maximum time in seconds to cache a document</td></tr>
855 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheMaxExpire <var>seconds</var></code></td></tr>
856 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheMaxExpire 86400 (one day)</code></td></tr>
857 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
858 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
859 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
861 <p>The <code class="directive">CacheMaxExpire</code> directive specifies the maximum number of
862 seconds for which cachable HTTP documents will be retained without checking the origin
863 server. Thus, documents will be out of date at most this number of seconds. This maximum
864 value is enforced even if an expiry date was supplied with the document.</p>
866 <div class="example"><p><code>
867 CacheMaxExpire 604800
871 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
872 <div class="directive-section"><h2><a name="CacheMinExpire" id="CacheMinExpire">CacheMinExpire</a> <a name="cacheminexpire" id="cacheminexpire">Directive</a></h2>
873 <table class="directive">
874 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The minimum time in seconds to cache a document</td></tr>
875 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheMinExpire <var>seconds</var></code></td></tr>
876 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheMinExpire 0</code></td></tr>
877 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
878 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
879 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
881 <p>The <code class="directive">CacheMinExpire</code> directive specifies the minimum number of
882 seconds for which cachable HTTP documents will be retained without checking the origin
883 server. This is only used if no valid expire time was supplied with the document.</p>
886 <div class="example"><p><code>
891 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
892 <div class="directive-section"><h2><a name="CacheQuickHandler" id="CacheQuickHandler">CacheQuickHandler</a> <a name="cachequickhandler" id="cachequickhandler">Directive</a></h2>
893 <table class="directive">
894 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Run the cache from the quick handler.</td></tr>
895 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheQuickHandler <var>on|off</var></code></td></tr>
896 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheQuickHandler on</code></td></tr>
897 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
898 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
899 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
901 <p>The <code class="directive"><a href="#cachequickhandler">CacheQuickHandler</a></code> directive
902 controls the phase in which the cache is handled.</p>
904 <p>In the default enabled configuration, the cache operates within the quick
905 handler phase. This phase short circuits the majority of server processing,
906 and represents the most performant mode of operation for a typical server.
907 The cache <strong>bolts onto</strong> the front of the server, and the
908 majority of server processing is avoided.</p>
910 <p>When disabled, the cache operates as a normal handler, and is subject to
911 the full set of phases when handling a server request. While this mode is
912 slower than the default, it allows the cache to be used in cases where full
913 processing is required, such as when content is subject to authorisation.</p>
915 <div class="example"><p><code>
916 # Run cache as a normal handler<br />
917 CacheQuickHandler off<br /><br />
920 <p>It is also possible, when the quick handler is disabled, for the
921 administrator to choose the precise location within the filter chain where
922 caching is to be performed, by adding the <strong>CACHE</strong> filter to
925 <div class="example"><p><code>
926 # Cache content before mod_include and mod_deflate<br />
927 CacheQuickHandler off<br />
928 AddOutputFilterByType CACHE;INCLUDES;DEFLATE text/html<br /><br />
931 <p>If the CACHE filter is specified more than once, the last instance will
936 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
937 <div class="directive-section"><h2><a name="CacheStaleOnError" id="CacheStaleOnError">CacheStaleOnError</a> <a name="cachestaleonerror" id="cachestaleonerror">Directive</a></h2>
938 <table class="directive">
939 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Serve stale content in place of 5xx responses.</td></tr>
940 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheStaleOnError <var>on|off</var></code></td></tr>
941 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheStaleOnError on</code></td></tr>
942 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
943 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
944 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
945 <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.3.9 and later</td></tr>
947 <p>When the <code class="directive"><a href="#cachestaleonerror">CacheStaleOnError</a></code> directive
948 is switched on, and when stale data is available in the cache, the cache will
949 respond to 5xx responses from the backend by returning the stale data instead of
950 the 5xx response. While the Cache-Control headers sent by clients will be respected,
951 and the raw 5xx responses returned to the client on request, the 5xx response so
952 returned to the client will not invalidate the content in the cache.</p>
954 <div class="example"><p><code>
955 # Serve stale data on error.<br />
956 CacheStaleOnError on<br />
961 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
962 <div class="directive-section"><h2><a name="CacheStoreExpired" id="CacheStoreExpired">CacheStoreExpired</a> <a name="cachestoreexpired" id="cachestoreexpired">Directive</a></h2>
963 <table class="directive">
964 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Attempt to cache responses that the server reports as expired</td></tr>
965 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheStoreExpired On|Off</code></td></tr>
966 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheStoreExpired Off</code></td></tr>
967 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
968 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
969 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
971 <p>Since httpd 2.2.4, responses which have already expired are not
972 stored in the cache. The <code class="directive">CacheStoreExpired</code>
973 directive allows this behavior to be overridden.
974 <code class="directive">CacheStoreExpired</code> On
975 tells the server to attempt to cache the resource if it is stale.
976 Subsequent requests would trigger an If-Modified-Since request of
977 the origin server, and the response may be fulfilled from cache
978 if the backend resource has not changed.</p>
980 <div class="example"><p><code>
985 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
986 <div class="directive-section"><h2><a name="CacheStoreNoStore" id="CacheStoreNoStore">CacheStoreNoStore</a> <a name="cachestorenostore" id="cachestorenostore">Directive</a></h2>
987 <table class="directive">
988 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Attempt to cache requests or responses that have been marked as no-store.</td></tr>
989 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheStoreNoStore On|Off</code></td></tr>
990 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheStoreNoStore Off</code></td></tr>
991 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
992 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
993 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
995 <p>Ordinarily, requests or responses with Cache-Control: no-store header
996 values will not be stored in the cache. The
997 <code class="directive">CacheStoreNoCache</code> directive allows this
998 behavior to be overridden. <code class="directive">CacheStoreNoCache</code> On
999 tells the server to attempt to cache the resource even if it contains
1000 no-store header values. Resources requiring authorization will
1001 <em>never</em> be cached.</p>
1003 <div class="example"><p><code>
1004 CacheStoreNoStore On
1007 <div class="warning"><h3>Warning:</h3>
1008 As described in RFC 2616, the no-store directive is intended to
1009 "prevent the inadvertent release or retention of sensitive information
1010 (for example, on backup tapes)." Enabling this option could store
1011 sensitive information in the cache. You are hereby warned.
1016 <li><code class="directive"><a href="#cacheignorecachecontrol">CacheIgnoreCacheControl</a></code></li>
1017 <li><code class="directive"><a href="#cachestoreprivate">CacheStorePrivate</a></code></li>
1020 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
1021 <div class="directive-section"><h2><a name="CacheStorePrivate" id="CacheStorePrivate">CacheStorePrivate</a> <a name="cachestoreprivate" id="cachestoreprivate">Directive</a></h2>
1022 <table class="directive">
1023 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Attempt to cache responses that the server has marked as private</td></tr>
1024 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheStorePrivate On|Off</code></td></tr>
1025 <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheStorePrivate Off</code></td></tr>
1026 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
1027 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
1028 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr>
1030 <p>Ordinarily, responses with Cache-Control: private header values will not
1031 be stored in the cache. The <code class="directive">CacheStorePrivate</code>
1032 directive allows this behavior to be overridden.
1033 <code class="directive">CacheStorePrivate</code> On
1034 tells the server to attempt to cache the resource even if it contains
1035 private header values. Resources requiring authorization will
1036 <em>never</em> be cached.</p>
1038 <div class="example"><p><code>
1039 CacheStorePrivate On
1042 <div class="warning"><h3>Warning:</h3>
1043 This directive will allow caching even if the upstream server has
1044 requested that the resource not be cached. This directive is only
1045 ideal for a 'private' cache.
1050 <li><code class="directive"><a href="#cacheignorecachecontrol">CacheIgnoreCacheControl</a></code></li>
1051 <li><code class="directive"><a href="#cachestorenostore">CacheStoreNoStore</a></code></li>
1055 <div class="bottomlang">
1056 <p><span>Available Languages: </span><a href="../en/mod/mod_cache.html" title="English"> en </a> |
1057 <a href="../fr/mod/mod_cache.html" hreflang="fr" rel="alternate" title="Français"> fr </a> |
1058 <a href="../ja/mod/mod_cache.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
1059 <a href="../ko/mod/mod_cache.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
1060 </div><div id="footer">
1061 <p class="apache">Copyright 2011 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>
1062 <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>