]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_cache.xml
Minor nitpick - We've attempted to standardize on American spelling.
[apache] / docs / manual / mod / mod_cache.xml
1 <?xml version="1.0"?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
5
6 <!--
7  Licensed to the Apache Software Foundation (ASF) under one or more
8  contributor license agreements.  See the NOTICE file distributed with
9  this work for additional information regarding copyright ownership.
10  The ASF licenses this file to You under the Apache License, Version 2.0
11  (the "License"); you may not use this file except in compliance with
12  the License.  You may obtain a copy of the License at
13
14      http://www.apache.org/licenses/LICENSE-2.0
15
16  Unless required by applicable law or agreed to in writing, software
17  distributed under the License is distributed on an "AS IS" BASIS,
18  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  See the License for the specific language governing permissions and
20  limitations under the License.
21 -->
22
23 <modulesynopsis metafile="mod_cache.xml.meta">
24
25 <name>mod_cache</name>
26 <description>Content cache keyed to URIs.</description>
27 <status>Extension</status>
28 <sourcefile>mod_cache.c</sourcefile>
29 <identifier>cache_module</identifier>
30
31 <summary>
32     <note type="warning">This module should be used with care, as when the
33     <directive module="mod_cache">CacheQuickHandler</directive> directive is
34     in its default value of <strong>on</strong>, the <directive 
35     module="mod_authz_host">Allow</directive> and <directive 
36     module="mod_authz_host">Deny</directive> directives will be circumvented.
37     You should not enable quick handler caching for any content to which you
38     wish to limit access by client host name, address or environment
39     variable.</note>  
40
41     <p><module>mod_cache</module> implements an <a
42     href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a> compliant HTTP
43     content cache that can be used to cache either local or proxied content.
44     <module>mod_cache</module> requires the services of one or more storage
45     management modules. One storage management module is included in
46     the base Apache distribution:</p>
47     <dl>
48     <dt><module>mod_disk_cache</module></dt>
49     <dd>implements a disk based storage manager.</dd>
50     </dl>
51
52     <p>Content is stored in and retrieved from the cache using URI based keys. Content with
53     access protection is not cached.</p>
54     <p>Further details, discussion, and examples, are provided in the
55     <a href="../caching.html">Caching Guide</a>.</p>
56 </summary>
57 <seealso><a href="../caching.html">Caching Guide</a></seealso>
58
59 <section id="related"><title>Related Modules and Directives</title>
60     <related>
61       <modulelist>
62         <module>mod_disk_cache</module>
63       </modulelist>
64       <directivelist>
65         <directive module="mod_disk_cache">CacheRoot</directive>
66         <directive module="mod_disk_cache">CacheDirLevels</directive>
67         <directive module="mod_disk_cache">CacheDirLength</directive>
68         <directive module="mod_disk_cache">CacheMinFileSize</directive>
69         <directive module="mod_disk_cache">CacheMaxFileSize</directive>
70       </directivelist>
71     </related>
72 </section>
73
74 <section id="sampleconf"><title>Sample Configuration</title>
75     <example><title>Sample httpd.conf</title>
76       #<br />
77       # Sample Cache Configuration<br />
78       #<br />
79       LoadModule cache_module modules/mod_cache.so<br />
80       <br />
81       &lt;IfModule mod_cache.c&gt;<br />
82       <indent>
83         LoadModule disk_cache_module modules/mod_disk_cache.so<br />
84         &lt;IfModule mod_disk_cache.c&gt;<br />
85         <indent>
86           CacheRoot c:/cacheroot<br />
87           CacheEnable disk  /<br />
88           CacheDirLevels 5<br />
89           CacheDirLength 3<br />
90         </indent>
91         &lt;/IfModule&gt; <br />
92         <br />
93         # When acting as a proxy, don't cache the list of security updates<br />
94         CacheDisable http://security.update.server/update-list/<br />
95       </indent>
96       &lt;/IfModule&gt;
97     </example>
98 </section>
99
100 <section id="thunderingherd"><title>Avoiding the Thundering Herd</title>
101   <p>When a cached entry becomes stale, <module>mod_cache</module> will submit
102   a conditional request to the backend, which is expected to confirm whether the
103   cached entry is still fresh, and send an updated entity if not.</p>
104   <p>A small but finite amount of time exists between the time the cached entity
105   becomes stale, and the time the stale entity is fully refreshed. On a busy
106   server, a significant number of requests might arrive during this time, and
107   cause a <strong>thundering herd</strong> of requests to strike the backend
108   suddenly and unpredicably.</p>
109   <p>To keep the thundering herd at bay, the <directive>CacheLock</directive>
110   directive can be used to define a directory in which locks are created for
111   URLs <strong>in flight</strong>. The lock is used as a <strong>hint</strong>
112   by other requests to either suppress an attempt to cache (someone else has
113   gone to fetch the entity), or to indicate that a stale entry is being refreshed
114   (stale content will be returned in the mean time).
115   </p>
116   <section>
117     <title>Initial caching of an entry</title>
118     <p>When an entity is cached for the first time, a lock will be created for the
119     entity until the response has been fully cached. During the lifetime of the
120     lock, the cache will suppress the second and subsequent attempt to cache the
121     same entity. While this doesn't hold back the thundering herd, it does stop
122     the cache attempting to cache the same entity multiple times simultaneously.
123     </p>
124   </section>
125   <section>
126     <title>Refreshment of a stale entry</title>
127     <p>When an entity reaches its freshness lifetime and becomes stale, a lock
128     will be created for the entity until the response has either been confirmed as
129     still fresh, or replaced by the backend. During the lifetime of the lock, the
130     second and subsequent incoming request will cause stale data to be returned,
131     and the thundering herd is kept at bay.</p>
132   </section>
133   <section>
134     <title>Locks and Cache-Control: no-cache</title>
135     <p>Locks are used as a <strong>hint only</strong> to enable the cache to be
136     more gentle on backend servers, however the lock can be overridden if necessary.
137     If the client sends a request with a Cache-Control header forcing a reload, any
138     lock that may be present will be ignored, and the client's request will be
139     honored immediately and the cached entry refreshed.</p>
140     <p>As a further safety mechanism, locks have a configurable maximum age.
141     Once this age has been reached, the lock is removed, and a new request is
142     given the opportunity to create a new lock. This maximum age can be set using
143     the <directive>CacheLockMaxAge</directive> directive, and defaults to 5
144     seconds.
145     </p>
146   </section>
147   <section>
148     <title>Example configuration</title>
149     <example><title>Enabling the cache lock</title>
150       #<br />
151       # Enable the cache lock<br />
152       #<br />
153       &lt;IfModule mod_cache.c&gt;<br />
154       <indent>
155         CacheLock on<br />
156         CacheLockPath /tmp/mod_cache-lock<br />
157         CacheLockMaxAge 5<br />
158       </indent>
159       &lt;/IfModule&gt;
160     </example>
161   </section>
162 </section>
163
164 <section id="finecontrol"><title>Fine Control with the CACHE Filter</title>
165   <p>Under the default mode of cache operation, the cache runs as a quick handler,
166   short circuiting the majority of server processing and offering the highest
167   cache performance available.</p>
168   
169   <p>In this mode, the cache <strong>bolts onto</strong> the front of the server,
170   acting as if a free standing RFC2616 caching proxy had been placed in front of
171   the server.</p>
172   
173   <p>While this mode offers the best performance, the administrator may find that
174   under certain circumstances they may want to perform further processing on the
175   request after the request is cached, such as to inject personalisation into the
176   cached page, or to apply authorisation restrictions to the content. Under these
177   circumstances, an administrator is often forced to place independent reverse
178   proxy servers either behind or in front of the caching server to achieve this.</p>
179
180   <p>To solve this problem the <directive module="mod_cache">CacheQuickHandler
181   </directive> directive can be set to <strong>off</strong>, and the server will
182   process all phases normally handled by a non-cached request, including the
183   <strong>authentication and authorisation</strong> phases.</p>
184
185   <p>In addition, the administrator may optionally specify the <strong>precise point
186   within the filter chain</strong> where caching is to take place by adding the
187   <strong>CACHE</strong> filter to the output filter chain.</p>
188
189   <p>For example, to cache content before applying compression to the response,
190   place the <strong>CACHE</strong> filter before the <strong>DEFLATE</strong>
191   filter as in the example below:</p>
192
193   <example>
194     # Cache content before optional compression<br />
195     CacheQuickHandler off<br />
196     AddOutputFilterByType CACHE;DEFLATE text/plain<br /><br />
197   </example>
198
199   <p>Another option is to have content cached before personalisation is applied
200   by <module>mod_include</module> (or another content processing filter). In this
201   example templates containing tags understood by
202   <module>mod_include</module> are cached before being parsed:</p>
203
204   <example>
205     # Cache content before mod_include and mod_deflate<br />
206     CacheQuickHandler off<br />
207     AddOutputFilterByType CACHE;INCLUDES;DEFLATE text/html<br /><br />
208   </example>
209
210   <p>You may place the <strong>CACHE</strong> filter anywhere you wish within the
211   filter chain. In this example, content is cached after being parsed by
212   <module>mod_include</module>, but before being processed by
213   <module>mod_deflate</module>:</p>
214
215   <example>
216     # Cache content between mod_include and mod_deflate<br />
217     CacheQuickHandler off<br />
218     AddOutputFilterByType INCLUDES;CACHE;DEFLATE text/html<br /><br />
219   </example>
220
221   <note type="warning"><title>Warning:</title>If the location of the
222   <strong>CACHE</strong> filter in the filter chain is changed for any reason,
223   you may need to <strong>flush your cache</strong> to ensure that your data
224   served remains consistent. <module>mod_cache</module> is not in a position
225   to enforce this for you.</note>
226
227 </section>
228
229 <section id="status"><title>Cache Status and Logging</title>
230   <p>Once <module>mod_cache</module> has made a decision as to whether or not
231   an entity is to be served from cache, the detailed reason for the decision
232   is written to the subprocess environment within the request under the
233   <strong>cache-status</strong> key. This reason can be logged by the
234   <directive module="mod_log_config">LogFormat</directive> directive as
235   follows:</p>
236
237   <example>
238     LogFormat "%{cache-status}e ..."
239   </example>
240
241   <p>Based on the caching decision made, the reason is also written to the
242   subprocess environment under one the following three keys, as appropriate:</p>
243
244   <dl>
245     <dt>cache-hit</dt><dd>The response was served from cache.</dd>
246     <dt>cache-revalidate</dt><dd>The response was stale and was successfully
247       revalidated, then served from cache.</dd>
248     <dt>cache-miss</dt><dd>The response was served from the upstream server.</dd>
249   </dl>
250
251   <p>This makes it possible to support conditional logging of cached requests
252   as per the following example:</p>
253
254   <example>
255     CustomLog cached-requests.log common env=cache-hit<br />
256     CustomLog uncached-requests.log common env=cache-miss<br />
257     CustomLog revalidated-requests.log common env=cache-revalidate<br />
258   </example>
259
260 </section>
261     
262 <directivesynopsis>
263 <name>CacheEnable</name>
264 <description>Enable caching of specified URLs using a specified storage
265 manager</description>
266 <syntax>CacheEnable <var>cache_type</var> <var>url-string</var></syntax>
267 <contextlist><context>server config</context><context>virtual host</context>
268 </contextlist>
269
270 <usage>
271     <p>The <directive>CacheEnable</directive> directive instructs
272     <module>mod_cache</module> to cache urls at or below
273     <var>url-string</var>. The cache storage manager is specified with the
274     <var>cache_type</var> argument. If the <directive>CacheEnable</directive>
275     directive is placed inside a <directive type="section">Location</directive>
276     directive, the <var>url-string</var> becomes optional.
277     <var>cache_type</var> <code>disk</code> instructs
278     <module>mod_cache</module> to use the disk based storage manager
279     implemented by <module>mod_disk_cache</module>.</p>
280     <p>In the event that the URL space overlaps between different
281     <directive>CacheEnable</directive> directives (as in the example below),
282     each possible storage manager will be run until the first one that
283     actually processes the request. The order in which the storage managers are
284     run is determined by the order of the <directive>CacheEnable</directive>
285     directives in the configuration file.</p>
286
287     <p>When acting as a forward proxy server, <var>url-string</var> can
288     also be used to specify remote sites and proxy protocols which 
289     caching should be enabled for.</p>
290  
291     <example>
292       # Cache proxied url's<br />
293       CacheEnable  disk  /<br /><br />
294       # Cache FTP-proxied url's<br />
295       CacheEnable  disk  ftp://<br /><br />
296       # Cache content from www.apache.org<br />
297       CacheEnable  disk  http://www.apache.org/<br />
298     </example>
299
300     <p>A hostname starting with a <strong>"*"</strong> matches all hostnames with
301     that suffix. A hostname starting with <strong>"."</strong> matches all
302     hostnames containing the domain components that follow.</p>
303
304     <example>
305       # Match www.apache.org, and fooapache.org<br />
306       CacheEnable  disk  http://*apache.org/<br />
307       # Match www.apache.org, but not fooapache.org<br />
308       CacheEnable  disk  http://.apache.org/<br />
309     </example>
310
311     <p> The <code>no-cache</code> environment variable can be set to 
312     disable caching on a finer grained set of resources in versions
313     2.2.12 and later.</p>
314
315 </usage>
316 <seealso><a href="../env.html">Environment Variables in Apache</a></seealso>
317 </directivesynopsis>
318
319 <directivesynopsis>
320 <name>CacheDisable</name>
321 <description>Disable caching of specified URLs</description>
322 <syntax>CacheDisable <var>url-string</var> | <var>on</var></syntax>
323 <contextlist><context>server config</context><context>virtual host</context>
324 </contextlist>
325
326 <usage>
327     <p>The <directive>CacheDisable</directive> directive instructs
328     <module>mod_cache</module> to <em>not</em> cache urls at or below
329     <var>url-string</var>.</p>
330
331     <example><title>Example</title>
332       CacheDisable /local_files
333     </example>
334
335     <p>If used in a <directive type="section">Location</directive> directive,
336     the path needs to be specified below the Location, or if the word "on"
337     is used, caching for the whole location will be disabled.</p>
338
339     <example><title>Example</title>
340       &lt;Location /foo&gt;<br />
341         CacheDisable on<br />
342       &lt;/Location&gt;<br />
343     </example>
344
345     <p> The <code>no-cache</code> environment variable can be set to 
346     disable caching on a finer grained set of resources in versions
347     2.2.12 and later.</p>
348
349 </usage>
350 <seealso><a href="../env.html">Environment Variables in Apache</a></seealso>
351 </directivesynopsis>
352 <directivesynopsis>
353 <name>CacheMaxExpire</name>
354 <description>The maximum time in seconds to cache a document</description>
355 <syntax>CacheMaxExpire <var>seconds</var></syntax>
356 <default>CacheMaxExpire 86400 (one day)</default>
357 <contextlist><context>server config</context><context>virtual host</context>
358 </contextlist>
359
360 <usage>
361     <p>The <directive>CacheMaxExpire</directive> directive specifies the maximum number of
362     seconds for which cachable HTTP documents will be retained without checking the origin
363     server. Thus, documents will be out of date at most this number of seconds. This maximum
364     value is enforced even if an expiry date was supplied with the document.</p>
365
366     <example>
367       CacheMaxExpire 604800
368     </example>
369 </usage>
370 </directivesynopsis>
371
372 <directivesynopsis>
373 <name>CacheMinExpire</name>
374 <description>The minimum time in seconds to cache a document</description>
375 <syntax>CacheMinExpire <var>seconds</var></syntax>
376 <default>CacheMinExpire 0</default>
377 <contextlist><context>server config</context><context>virtual host</context>
378 </contextlist>
379
380 <usage>
381     <p>The <directive>CacheMinExpire</directive> directive specifies the minimum number of
382     seconds for which cachable HTTP documents will be retained without checking the origin
383     server. This is only used if no valid expire time was supplied with the document.</p>
384
385
386     <example>
387       CacheMinExpire 3600
388     </example>
389 </usage>
390 </directivesynopsis>
391
392 <directivesynopsis>
393 <name>CacheDefaultExpire</name>
394 <description>The default duration to cache a document when no expiry date is specified.</description>
395 <syntax>CacheDefaultExpire <var>seconds</var></syntax>
396 <default>CacheDefaultExpire 3600 (one hour)</default>
397 <contextlist><context>server config</context><context>virtual host</context>
398 </contextlist>
399
400 <usage>
401     <p>The <directive>CacheDefaultExpire</directive> directive specifies a default time,
402     in seconds, to cache a document if neither an expiry date nor last-modified date are provided
403     with the document. The value specified with the <directive>CacheMaxExpire</directive>
404     directive does <em>not</em> override this setting.</p>
405
406     <example>
407       CacheDefaultExpire 86400
408     </example>
409 </usage>
410 </directivesynopsis>
411
412 <directivesynopsis>
413 <name>CacheIgnoreNoLastMod</name>
414 <description>Ignore the fact that a response has no Last Modified
415 header.</description>
416 <syntax>CacheIgnoreNoLastMod On|Off</syntax>
417 <default>CacheIgnoreNoLastMod Off</default>
418 <contextlist><context>server config</context><context>virtual host</context>
419 </contextlist>
420
421 <usage>
422     <p>Ordinarily, documents without a last-modified date are not cached.
423     Under some circumstances the last-modified date is removed (during
424     <module>mod_include</module> processing for example) or not provided
425     at all. The <directive>CacheIgnoreNoLastMod</directive> directive
426     provides a way to specify that documents without last-modified dates
427     should be considered for caching, even without a last-modified date.
428     If neither a last-modified date nor an expiry date are provided with
429     the document then the value specified by the
430     <directive>CacheDefaultExpire</directive> directive will be used to
431     generate an expiration date.</p>
432
433     <example>
434       CacheIgnoreNoLastMod On
435     </example>
436 </usage>
437 </directivesynopsis>
438
439 <directivesynopsis>
440 <name>CacheIgnoreCacheControl</name>
441 <description>Ignore request to not serve cached content to client</description>
442 <syntax>CacheIgnoreCacheControl On|Off</syntax>
443 <default>CacheIgnoreCacheControl Off</default>
444 <contextlist><context>server config</context><context>virtual host</context>
445 </contextlist>
446
447 <usage>
448     <p>Ordinarily, requests containing a Cache-Control: no-cache or
449     Pragma: no-cache header value will not be served from the cache.  The
450     <directive>CacheIgnoreCacheControl</directive> directive allows this
451     behavior to be overridden.  <directive>CacheIgnoreCacheControl On</directive>
452     tells the server to attempt to serve the resource from the cache even
453     if the request contains no-cache header values.  Resources requiring
454     authorization will <em>never</em> be cached.</p>
455
456     <example>
457       CacheIgnoreCacheControl On
458     </example>
459
460     <note type="warning"><title>Warning:</title>
461        This directive will allow serving from the cache even if the client has
462        requested that the document not be served from the cache.  This might
463        result in stale content being served.
464     </note>
465 </usage>
466 <seealso><directive module="mod_cache">CacheStorePrivate</directive></seealso>
467 <seealso><directive module="mod_cache">CacheStoreNoStore</directive></seealso>
468 </directivesynopsis>
469
470 <directivesynopsis>
471 <name>CacheIgnoreQueryString</name>
472 <description>Ignore query string when caching</description>
473 <syntax>CacheIgnoreQueryString On|Off</syntax>
474 <default>CacheIgnoreQueryString Off</default>
475 <contextlist><context>server config</context><context>virtual host</context>
476 </contextlist>
477
478 <usage>
479     <p>Ordinarily, requests with query string parameters are cached separately
480     for each unique query string. This is according to RFC 2616/13.9 done only
481     if an expiration time is specified. The 
482     <directive>CacheIgnoreQueryString</directive> directive tells the cache to
483     cache requests even if no expiration time is specified, and to reply with 
484     a cached reply even if the query string differs. From a caching point of
485     view the request is treated as if having no query string when this 
486     directive is enabled.</p>
487
488     <example>
489       CacheIgnoreQueryString On
490     </example>
491
492 </usage>
493 </directivesynopsis>
494
495 <directivesynopsis>
496 <name>CacheLastModifiedFactor</name>
497 <description>The factor used to compute an expiry date based on the
498 LastModified date.</description>
499 <syntax>CacheLastModifiedFactor <var>float</var></syntax>
500 <default>CacheLastModifiedFactor 0.1</default>
501 <contextlist><context>server config</context><context>virtual host</context>
502 </contextlist>
503
504 <usage>
505     <p>In the event that a document does not provide an expiry date but does
506     provide a last-modified date, an expiry date can be calculated based on
507     the time since the document was last modified. The
508     <directive>CacheLastModifiedFactor</directive> directive specifies a
509     <var>factor</var> to be used in the generation of this expiry date
510     according to the following formula:
511
512     <code>expiry-period = time-since-last-modified-date * <var>factor</var>
513     expiry-date = current-date + expiry-period</code>
514
515     For example, if the document was last modified 10 hours ago, and
516     <var>factor</var> is 0.1 then the expiry-period will be set to
517     10*0.1 = 1 hour. If the current time was 3:00pm then the computed
518     expiry-date would be 3:00pm + 1hour = 4:00pm.
519
520     If the expiry-period would be longer than that set by
521     <directive>CacheMaxExpire</directive>, then the latter takes
522     precedence.</p>
523
524     <example>
525       CacheLastModifiedFactor 0.5
526     </example>
527 </usage>
528 </directivesynopsis>
529
530 <directivesynopsis>
531 <name>CacheIgnoreHeaders</name>
532 <description>Do not store the given HTTP header(s) in the cache.
533 </description>
534 <syntax>CacheIgnoreHeaders <var>header-string</var> [<var>header-string</var>] ...</syntax>
535 <default>CacheIgnoreHeaders None</default>
536 <contextlist><context>server config</context><context>virtual host</context>
537 </contextlist>
538
539 <usage>
540     <p>According to RFC 2616, hop-by-hop HTTP headers are not stored in
541     the cache.  The following HTTP headers are hop-by-hop headers and thus
542     do not get stored in the cache in <em>any</em> case regardless of the
543     setting of <directive>CacheIgnoreHeaders</directive>:</p>
544
545     <ul>
546       <li><code>Connection</code></li>
547       <li><code>Keep-Alive</code></li>
548       <li><code>Proxy-Authenticate</code></li>
549       <li><code>Proxy-Authorization</code></li>
550       <li><code>TE</code></li>
551       <li><code>Trailers</code></li>
552       <li><code>Transfer-Encoding</code></li>
553       <li><code>Upgrade</code></li>
554     </ul>
555
556     <p><directive>CacheIgnoreHeaders</directive> specifies additional HTTP
557     headers that should not to be stored in the cache.  For example, it makes
558     sense in some cases to prevent cookies from being stored in the cache.</p>
559
560     <p><directive>CacheIgnoreHeaders</directive> takes a space separated list
561     of HTTP headers that should not be stored in the cache. If only hop-by-hop
562     headers not should be stored in the cache (the RFC 2616 compliant
563     behaviour), <directive>CacheIgnoreHeaders</directive> can be set to
564     <code>None</code>.</p>
565
566     <example><title>Example 1</title>
567       CacheIgnoreHeaders Set-Cookie
568     </example>
569
570     <example><title>Example 2</title>
571       CacheIgnoreHeaders None
572     </example>
573
574     <note type="warning"><title>Warning:</title>
575       If headers like <code>Expires</code> which are needed for proper cache
576       management are not stored due to a
577       <directive>CacheIgnoreHeaders</directive> setting, the behaviour of
578       mod_cache is undefined.
579     </note>
580 </usage>
581 </directivesynopsis>
582
583 <directivesynopsis>
584 <name>CacheIgnoreURLSessionIdentifiers</name>
585 <description>Ignore defined session identifiers encoded in the URL when caching
586 </description>
587 <syntax>CacheIgnoreURLSessionIdentifiers <var>identifier</var> [<var>identifier</var>] ...</syntax>
588 <default>CacheIgnoreURLSessionIdentifiers None</default>
589 <contextlist><context>server config</context><context>virtual host</context>
590 </contextlist>
591
592 <usage>
593     <p>Sometimes applications encode the session identifier into the URL like in the following
594     Examples:
595     </p>
596     <ul>
597       <li><code>/someapplication/image.gif;jsessionid=123456789</code></li>
598       <li><code>/someapplication/image.gif?PHPSESSIONID=12345678</code></li>
599     </ul>
600     <p>This causes cachable resources to be stored separately for each session, which
601     is often not desired. <directive>CacheIgnoreURLSessionIdentifiers</directive> lets
602     define a list of identifiers that are removed from the key that is used to identify
603     an entity in the cache, such that cachable resources are not stored separately for
604     each session.
605     </p>
606     <p><code>CacheIgnoreURLSessionIdentifiers None</code> clears the list of ignored
607     identifiers. Otherwise, each identifier is added to the list.</p>
608
609     <example><title>Example 1</title>
610       CacheIgnoreURLSessionIdentifiers jsessionid
611     </example>
612
613     <example><title>Example 2</title>
614       CacheIgnoreURLSessionIdentifiers None
615     </example>
616
617 </usage>
618 </directivesynopsis>
619
620 <directivesynopsis>
621 <name>CacheStoreExpired</name>
622 <description>Attempt to cache responses that the server reports as expired</description>
623 <syntax>CacheStoreExpired On|Off</syntax>
624 <default>CacheStoreExpired Off</default>
625 <contextlist><context>server config</context><context>virtual host</context>
626 </contextlist>
627
628 <usage>
629     <p>Since httpd 2.2.4, responses which have already expired are not
630        stored in the cache.  The <directive>CacheStoreExpired</directive>
631        directive allows this behavior to be overridden.
632        <directive>CacheStoreExpired</directive> On
633        tells the server to attempt to cache the resource if it is stale.
634        Subsequent requests would trigger an If-Modified-Since request of
635        the origin server, and the response may be fulfilled from cache
636        if the backend resource has not changed.</p>
637
638     <example>
639       CacheStoreExpired On
640     </example>
641 </usage>
642 </directivesynopsis>
643
644 <directivesynopsis>
645 <name>CacheStorePrivate</name>
646 <description>Attempt to cache responses that the server has marked as private</description>
647 <syntax>CacheStorePrivate On|Off</syntax>
648 <default>CacheStorePrivate Off</default>
649 <contextlist><context>server config</context><context>virtual host</context>
650 </contextlist>
651
652 <usage>
653     <p>Ordinarily, responses with Cache-Control: private header values will not
654        be stored in the cache.  The <directive>CacheStorePrivate</directive>
655        directive allows this behavior to be overridden.
656        <directive>CacheStorePrivate</directive> On
657        tells the server to attempt to cache the resource even if it contains
658        private header values.  Resources requiring authorization will
659        <em>never</em> be cached.</p>
660
661     <example>
662       CacheStorePrivate On
663     </example>
664
665     <note type="warning"><title>Warning:</title>
666        This directive will allow caching even if the upstream server has
667        requested that the resource not be cached.  This directive is only
668        ideal for a 'private' cache.
669     </note>
670 </usage>
671 <seealso><directive module="mod_cache">CacheIgnoreCacheControl</directive></seealso>
672 <seealso><directive module="mod_cache">CacheStoreNoStore</directive></seealso>
673 </directivesynopsis>
674
675 <directivesynopsis>
676 <name>CacheStoreNoStore</name>
677 <description>Attempt to cache requests or responses that have been marked as no-store.</description>
678 <syntax>CacheStoreNoStore On|Off</syntax>
679 <default>CacheStoreNoStore Off</default>
680 <contextlist><context>server config</context><context>virtual host</context>
681 </contextlist>
682
683 <usage>
684     <p>Ordinarily, requests or responses with Cache-Control: no-store header
685        values will not be stored in the cache.  The
686        <directive>CacheStoreNoCache</directive> directive allows this
687        behavior to be overridden.  <directive>CacheStoreNoCache</directive> On
688        tells the server to attempt to cache the resource even if it contains
689        no-store header values.  Resources requiring authorization will
690        <em>never</em> be cached.</p>
691
692     <example>
693       CacheStoreNoStore On
694     </example>
695
696     <note type="warning"><title>Warning:</title>
697        As described in RFC 2616, the no-store directive is intended to
698        "prevent the inadvertent release or retention of sensitive information
699        (for example, on backup tapes)."  Enabling this option could store
700        sensitive information in the cache.  You are hereby warned.
701     </note>
702 </usage>
703 <seealso><directive module="mod_cache">CacheIgnoreCacheControl</directive></seealso>
704 <seealso><directive module="mod_cache">CacheStorePrivate</directive></seealso>
705 </directivesynopsis>
706
707 <directivesynopsis>
708 <name>CacheLock</name>
709 <description>Enable the thundering herd lock.</description>
710 <syntax>CacheLock <var>on|off</var></syntax>
711 <default>CacheLock off</default>
712 <contextlist><context>server config</context><context>virtual host</context>
713 </contextlist>
714 <compatibility>Available in Apache 2.2.15 and later</compatibility>
715
716 <usage>
717   <p>The <directive>CacheLock</directive> directive enables the thundering herd lock
718   for the given URL space.</p>
719   
720   <p>In a minimal configuration the following directive is all that is needed to
721   enable the thundering herd lock in the default system temp directory.</p>
722
723   <example>
724     # Enable cache lock<br />
725     CacheLock on<br /><br />
726   </example>
727
728 </usage>
729 </directivesynopsis>
730
731 <directivesynopsis>
732 <name>CacheLockPath</name>
733 <description>Set the lock path directory.</description>
734 <syntax>CacheLockPath <var>directory</var></syntax>
735 <default>CacheLockPath /tmp/mod_cache-lock</default>
736 <contextlist><context>server config</context><context>virtual host</context>
737 </contextlist>
738     
739 <usage>
740   <p>The <directive>CacheLockPath</directive> directive allows you to specify the
741   directory in which the locks are created. By default, the system's temporary
742   folder is used. Locks consist of empty files that only exist for stale URLs
743   in flight, so is significantly less resource intensive than the traditional
744   disk cache.</p>
745
746 </usage>
747 </directivesynopsis>
748
749 <directivesynopsis>
750 <name>CacheLockMaxAge</name>
751 <description>Set the maximum possible age of a cache lock.</description>
752 <syntax>CacheLockMaxAge <var>integer</var></syntax>
753 <default>CacheLockMaxAge 5</default>
754 <contextlist><context>server config</context><context>virtual host</context>
755 </contextlist>
756     
757 <usage>
758   <p>The <directive>CacheLockMaxAge</directive> directive specifies the maximum
759   age of any cache lock.</p>
760   
761   <p>A lock older than this value in seconds will be ignored, and the next
762   incoming request will be given the opportunity to re-establish the lock.
763   This mechanism prevents a slow client taking an excessively long time to refresh
764   an entity.</p>
765   
766 </usage>
767 </directivesynopsis>
768
769 <directivesynopsis>
770   <name>CacheQuickHandler</name>
771   <description>Run the cache from the quick handler.</description>
772   <syntax>CacheQuickHandler <var>on|off</var></syntax>
773   <default>CacheQuickHandler on</default>
774   <contextlist><context>server config</context><context>virtual host</context>
775   </contextlist>
776
777   <usage>
778     <p>The <directive module="mod_cache">CacheQuickHandler</directive> directive
779     controls the phase in which the cache is handled.</p>
780
781     <p>In the default enabled configuration, the cache operates within the quick
782     handler phase. This phase short circuits the majority of server processing,
783     and represents the most performant mode of operation for a typical server.
784     The cache <strong>bolts onto</strong> the front of the server, and the
785     majority of server processing is avoided.</p>
786
787     <p>When disabled, the cache operates as a normal handler, and is subject to
788     the full set of phases when handling a server request. While this mode is
789     slower than the default, it allows the cache to be used in cases where full
790     processing is required, such as when content is subject to authorisation.</p>
791
792     <example>
793       # Run cache as a normal handler<br />
794       CacheQuickHandler off<br /><br />
795     </example>
796
797     <p>It is also possible, when the quick handler is disabled, for the
798     administrator to choose the precise location within the filter chain where
799     caching is to be performed, by adding the <strong>CACHE</strong> filter to
800     the chain.</p>
801
802     <example>
803       # Cache content before mod_include and mod_deflate<br />
804       CacheQuickHandler off<br />
805       AddOutputFilterByType CACHE;INCLUDES;DEFLATE text/html<br /><br />
806     </example>
807
808     <p>If the CACHE filter is specified more than once, the last instance will
809     apply.</p>
810
811   </usage>
812 </directivesynopsis>
813
814 <directivesynopsis>
815 <name>CacheHeader</name>
816 <description>Add an X-Cache header to the response.</description>
817 <syntax>CacheHeader <var>on|off</var></syntax>
818 <default>CacheHeader off</default>
819 <contextlist><context>server config</context>
820     <context>virtual host</context>
821     <context>directory</context>
822     <context>.htaccess</context>
823 </contextlist>
824 <compatibility>Available in Apache 2.3.9 and later</compatibility>
825   
826 <usage>
827   <p>When the <directive module="mod_cache">CacheHeader</directive> directive
828   is switched on, an <strong>X-Cache</strong> header will be added to the response
829   with the cache status of this response. If the normal handler is used, this
830   directive may appear within a <directive module="core">&lt;Directory&gt;</directive>
831   or <directive module="core">&lt;Location&gt;</directive> directive. If the quick
832   handler is used, this directive must appear within a server or virtual host
833   context, otherwise the setting will be ignored.</p>
834
835   <dl>
836     <dt><strong>HIT</strong></dt><dd>The entity was fresh, and was served from
837     cache.</dd>
838     <dt><strong>REVALIDATE</strong></dt><dd>The entity was stale, was successfully
839     revalidated and was served from cache.</dd>
840     <dt><strong>MISS</strong></dt><dd>The entity was fetched from the upstream
841       server and was not served from cache.</dd>
842   </dl>
843
844   <example>
845     # Enable the X-Cache header<br />
846     CacheHeader on<br />
847   </example>
848
849   <example>
850     X-Cache: HIT from localhost<br />
851   </example>
852
853 </usage>
854 </directivesynopsis>
855
856 <directivesynopsis>
857 <name>CacheDetailHeader</name>
858 <description>Add an X-Cache-Detail header to the response.</description>
859 <syntax>CacheDetailHeader <var>on|off</var></syntax>
860 <default>CacheDetailHeader off</default>
861 <contextlist><context>server config</context>
862       <context>virtual host</context>
863       <context>directory</context>
864       <context>.htaccess</context>
865 </contextlist>
866 <compatibility>Available in Apache 2.3.9 and later</compatibility>
867     
868 <usage>
869   <p>When the <directive module="mod_cache">CacheDetailHeader</directive> directive
870   is switched on, an <strong>X-Cache-Detail</strong> header will be added to the response
871   containing the detailed reason for a particular caching decision.</p>
872   
873   <p>It can be useful during development of cached RESTful services to have additional
874   information about the caching decision written to the response headers, so as to
875   confirm whether <code>Cache-Control</code> and other headers have been correctly
876   used by the service and client.</p>
877   
878   <p>If the normal handler is used, this directive may appear within a
879   <directive module="core">&lt;Directory&gt;</directive> or
880   <directive module="core">&lt;Location&gt;</directive> directive. If the quick handler
881   is used, this directive must appear within a server or virtual host context, otherwise
882   the setting will be ignored.</p>
883
884   <example>
885     # Enable the X-Cache-Detail header<br />
886     CacheDetailHeader on<br />
887   </example>
888
889   <example>
890     X-Cache-Detail: "conditional cache hit: entity refreshed" from localhost<br />
891   </example>
892
893 </usage>
894 </directivesynopsis>
895
896 </modulesynopsis>