]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_cache.xml
mod_cache: CacheLastModifiedFactor, CacheStoreNoStore, CacheStorePrivate,
[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>
358     <context>virtual host</context>
359     <context>directory</context>
360     <context>.htaccess</context>
361 </contextlist>
362
363 <usage>
364     <p>The <directive>CacheMaxExpire</directive> directive specifies the maximum number of
365     seconds for which cachable HTTP documents will be retained without checking the origin
366     server. Thus, documents will be out of date at most this number of seconds. This maximum
367     value is enforced even if an expiry date was supplied with the document.</p>
368
369     <example>
370       CacheMaxExpire 604800
371     </example>
372 </usage>
373 </directivesynopsis>
374
375 <directivesynopsis>
376 <name>CacheMinExpire</name>
377 <description>The minimum time in seconds to cache a document</description>
378 <syntax>CacheMinExpire <var>seconds</var></syntax>
379 <default>CacheMinExpire 0</default>
380 <contextlist><context>server config</context>
381   <context>virtual host</context>
382   <context>directory</context>
383   <context>.htaccess</context>
384 </contextlist>
385
386 <usage>
387     <p>The <directive>CacheMinExpire</directive> directive specifies the minimum number of
388     seconds for which cachable HTTP documents will be retained without checking the origin
389     server. This is only used if no valid expire time was supplied with the document.</p>
390
391
392     <example>
393       CacheMinExpire 3600
394     </example>
395 </usage>
396 </directivesynopsis>
397
398 <directivesynopsis>
399 <name>CacheDefaultExpire</name>
400 <description>The default duration to cache a document when no expiry date is specified.</description>
401 <syntax>CacheDefaultExpire <var>seconds</var></syntax>
402 <default>CacheDefaultExpire 3600 (one hour)</default>
403 <contextlist><context>server config</context>
404   <context>virtual host</context>
405   <context>directory</context>
406   <context>.htaccess</context>
407 </contextlist>
408
409 <usage>
410     <p>The <directive>CacheDefaultExpire</directive> directive specifies a default time,
411     in seconds, to cache a document if neither an expiry date nor last-modified date are provided
412     with the document. The value specified with the <directive>CacheMaxExpire</directive>
413     directive does <em>not</em> override this setting.</p>
414
415     <example>
416       CacheDefaultExpire 86400
417     </example>
418 </usage>
419 </directivesynopsis>
420
421 <directivesynopsis>
422 <name>CacheIgnoreNoLastMod</name>
423 <description>Ignore the fact that a response has no Last Modified
424 header.</description>
425 <syntax>CacheIgnoreNoLastMod On|Off</syntax>
426 <default>CacheIgnoreNoLastMod Off</default>
427 <contextlist><context>server config</context>
428   <context>virtual host</context>
429   <context>directory</context>
430   <context>.htaccess</context>
431 </contextlist>
432     
433 <usage>
434     <p>Ordinarily, documents without a last-modified date are not cached.
435     Under some circumstances the last-modified date is removed (during
436     <module>mod_include</module> processing for example) or not provided
437     at all. The <directive>CacheIgnoreNoLastMod</directive> directive
438     provides a way to specify that documents without last-modified dates
439     should be considered for caching, even without a last-modified date.
440     If neither a last-modified date nor an expiry date are provided with
441     the document then the value specified by the
442     <directive>CacheDefaultExpire</directive> directive will be used to
443     generate an expiration date.</p>
444
445     <example>
446       CacheIgnoreNoLastMod On
447     </example>
448 </usage>
449 </directivesynopsis>
450
451 <directivesynopsis>
452 <name>CacheIgnoreCacheControl</name>
453 <description>Ignore request to not serve cached content to client</description>
454 <syntax>CacheIgnoreCacheControl On|Off</syntax>
455 <default>CacheIgnoreCacheControl Off</default>
456 <contextlist><context>server config</context><context>virtual host</context>
457 </contextlist>
458
459 <usage>
460     <p>Ordinarily, requests containing a Cache-Control: no-cache or
461     Pragma: no-cache header value will not be served from the cache.  The
462     <directive>CacheIgnoreCacheControl</directive> directive allows this
463     behavior to be overridden.  <directive>CacheIgnoreCacheControl On</directive>
464     tells the server to attempt to serve the resource from the cache even
465     if the request contains no-cache header values.  Resources requiring
466     authorization will <em>never</em> be cached.</p>
467
468     <example>
469       CacheIgnoreCacheControl On
470     </example>
471
472     <note type="warning"><title>Warning:</title>
473        This directive will allow serving from the cache even if the client has
474        requested that the document not be served from the cache.  This might
475        result in stale content being served.
476     </note>
477 </usage>
478 <seealso><directive module="mod_cache">CacheStorePrivate</directive></seealso>
479 <seealso><directive module="mod_cache">CacheStoreNoStore</directive></seealso>
480 </directivesynopsis>
481
482 <directivesynopsis>
483 <name>CacheIgnoreQueryString</name>
484 <description>Ignore query string when caching</description>
485 <syntax>CacheIgnoreQueryString On|Off</syntax>
486 <default>CacheIgnoreQueryString Off</default>
487 <contextlist><context>server config</context><context>virtual host</context>
488 </contextlist>
489
490 <usage>
491     <p>Ordinarily, requests with query string parameters are cached separately
492     for each unique query string. This is according to RFC 2616/13.9 done only
493     if an expiration time is specified. The 
494     <directive>CacheIgnoreQueryString</directive> directive tells the cache to
495     cache requests even if no expiration time is specified, and to reply with 
496     a cached reply even if the query string differs. From a caching point of
497     view the request is treated as if having no query string when this 
498     directive is enabled.</p>
499
500     <example>
501       CacheIgnoreQueryString On
502     </example>
503
504 </usage>
505 </directivesynopsis>
506
507 <directivesynopsis>
508 <name>CacheLastModifiedFactor</name>
509 <description>The factor used to compute an expiry date based on the
510 LastModified date.</description>
511 <syntax>CacheLastModifiedFactor <var>float</var></syntax>
512 <default>CacheLastModifiedFactor 0.1</default>
513 <contextlist><context>server config</context>
514   <context>virtual host</context>
515   <context>directory</context>
516   <context>.htaccess</context>
517 </contextlist>
518     
519 <usage>
520     <p>In the event that a document does not provide an expiry date but does
521     provide a last-modified date, an expiry date can be calculated based on
522     the time since the document was last modified. The
523     <directive>CacheLastModifiedFactor</directive> directive specifies a
524     <var>factor</var> to be used in the generation of this expiry date
525     according to the following formula:
526
527     <code>expiry-period = time-since-last-modified-date * <var>factor</var>
528     expiry-date = current-date + expiry-period</code>
529
530     For example, if the document was last modified 10 hours ago, and
531     <var>factor</var> is 0.1 then the expiry-period will be set to
532     10*0.1 = 1 hour. If the current time was 3:00pm then the computed
533     expiry-date would be 3:00pm + 1hour = 4:00pm.
534
535     If the expiry-period would be longer than that set by
536     <directive>CacheMaxExpire</directive>, then the latter takes
537     precedence.</p>
538
539     <example>
540       CacheLastModifiedFactor 0.5
541     </example>
542 </usage>
543 </directivesynopsis>
544
545 <directivesynopsis>
546 <name>CacheIgnoreHeaders</name>
547 <description>Do not store the given HTTP header(s) in the cache.
548 </description>
549 <syntax>CacheIgnoreHeaders <var>header-string</var> [<var>header-string</var>] ...</syntax>
550 <default>CacheIgnoreHeaders None</default>
551 <contextlist><context>server config</context><context>virtual host</context>
552 </contextlist>
553
554 <usage>
555     <p>According to RFC 2616, hop-by-hop HTTP headers are not stored in
556     the cache.  The following HTTP headers are hop-by-hop headers and thus
557     do not get stored in the cache in <em>any</em> case regardless of the
558     setting of <directive>CacheIgnoreHeaders</directive>:</p>
559
560     <ul>
561       <li><code>Connection</code></li>
562       <li><code>Keep-Alive</code></li>
563       <li><code>Proxy-Authenticate</code></li>
564       <li><code>Proxy-Authorization</code></li>
565       <li><code>TE</code></li>
566       <li><code>Trailers</code></li>
567       <li><code>Transfer-Encoding</code></li>
568       <li><code>Upgrade</code></li>
569     </ul>
570
571     <p><directive>CacheIgnoreHeaders</directive> specifies additional HTTP
572     headers that should not to be stored in the cache.  For example, it makes
573     sense in some cases to prevent cookies from being stored in the cache.</p>
574
575     <p><directive>CacheIgnoreHeaders</directive> takes a space separated list
576     of HTTP headers that should not be stored in the cache. If only hop-by-hop
577     headers not should be stored in the cache (the RFC 2616 compliant
578     behaviour), <directive>CacheIgnoreHeaders</directive> can be set to
579     <code>None</code>.</p>
580
581     <example><title>Example 1</title>
582       CacheIgnoreHeaders Set-Cookie
583     </example>
584
585     <example><title>Example 2</title>
586       CacheIgnoreHeaders None
587     </example>
588
589     <note type="warning"><title>Warning:</title>
590       If headers like <code>Expires</code> which are needed for proper cache
591       management are not stored due to a
592       <directive>CacheIgnoreHeaders</directive> setting, the behaviour of
593       mod_cache is undefined.
594     </note>
595 </usage>
596 </directivesynopsis>
597
598 <directivesynopsis>
599 <name>CacheIgnoreURLSessionIdentifiers</name>
600 <description>Ignore defined session identifiers encoded in the URL when caching
601 </description>
602 <syntax>CacheIgnoreURLSessionIdentifiers <var>identifier</var> [<var>identifier</var>] ...</syntax>
603 <default>CacheIgnoreURLSessionIdentifiers None</default>
604 <contextlist><context>server config</context><context>virtual host</context>
605 </contextlist>
606
607 <usage>
608     <p>Sometimes applications encode the session identifier into the URL like in the following
609     Examples:
610     </p>
611     <ul>
612       <li><code>/someapplication/image.gif;jsessionid=123456789</code></li>
613       <li><code>/someapplication/image.gif?PHPSESSIONID=12345678</code></li>
614     </ul>
615     <p>This causes cachable resources to be stored separately for each session, which
616     is often not desired. <directive>CacheIgnoreURLSessionIdentifiers</directive> lets
617     define a list of identifiers that are removed from the key that is used to identify
618     an entity in the cache, such that cachable resources are not stored separately for
619     each session.
620     </p>
621     <p><code>CacheIgnoreURLSessionIdentifiers None</code> clears the list of ignored
622     identifiers. Otherwise, each identifier is added to the list.</p>
623
624     <example><title>Example 1</title>
625       CacheIgnoreURLSessionIdentifiers jsessionid
626     </example>
627
628     <example><title>Example 2</title>
629       CacheIgnoreURLSessionIdentifiers None
630     </example>
631
632 </usage>
633 </directivesynopsis>
634
635 <directivesynopsis>
636 <name>CacheStoreExpired</name>
637 <description>Attempt to cache responses that the server reports as expired</description>
638 <syntax>CacheStoreExpired On|Off</syntax>
639 <default>CacheStoreExpired Off</default>
640 <contextlist><context>server config</context>
641   <context>virtual host</context>
642   <context>directory</context>
643   <context>.htaccess</context>
644 </contextlist>
645
646 <usage>
647     <p>Since httpd 2.2.4, responses which have already expired are not
648        stored in the cache.  The <directive>CacheStoreExpired</directive>
649        directive allows this behavior to be overridden.
650        <directive>CacheStoreExpired</directive> On
651        tells the server to attempt to cache the resource if it is stale.
652        Subsequent requests would trigger an If-Modified-Since request of
653        the origin server, and the response may be fulfilled from cache
654        if the backend resource has not changed.</p>
655
656     <example>
657       CacheStoreExpired On
658     </example>
659 </usage>
660 </directivesynopsis>
661
662 <directivesynopsis>
663 <name>CacheStorePrivate</name>
664 <description>Attempt to cache responses that the server has marked as private</description>
665 <syntax>CacheStorePrivate On|Off</syntax>
666 <default>CacheStorePrivate Off</default>
667 <contextlist><context>server config</context>
668   <context>virtual host</context>
669   <context>directory</context>
670   <context>.htaccess</context>
671 </contextlist>
672
673 <usage>
674     <p>Ordinarily, responses with Cache-Control: private header values will not
675        be stored in the cache.  The <directive>CacheStorePrivate</directive>
676        directive allows this behavior to be overridden.
677        <directive>CacheStorePrivate</directive> On
678        tells the server to attempt to cache the resource even if it contains
679        private header values.  Resources requiring authorization will
680        <em>never</em> be cached.</p>
681
682     <example>
683       CacheStorePrivate On
684     </example>
685
686     <note type="warning"><title>Warning:</title>
687        This directive will allow caching even if the upstream server has
688        requested that the resource not be cached.  This directive is only
689        ideal for a 'private' cache.
690     </note>
691 </usage>
692 <seealso><directive module="mod_cache">CacheIgnoreCacheControl</directive></seealso>
693 <seealso><directive module="mod_cache">CacheStoreNoStore</directive></seealso>
694 </directivesynopsis>
695
696 <directivesynopsis>
697 <name>CacheStoreNoStore</name>
698 <description>Attempt to cache requests or responses that have been marked as no-store.</description>
699 <syntax>CacheStoreNoStore On|Off</syntax>
700 <default>CacheStoreNoStore Off</default>
701 <contextlist><context>server config</context>
702   <context>virtual host</context>
703   <context>directory</context>
704   <context>.htaccess</context>
705 </contextlist>
706
707 <usage>
708     <p>Ordinarily, requests or responses with Cache-Control: no-store header
709        values will not be stored in the cache.  The
710        <directive>CacheStoreNoCache</directive> directive allows this
711        behavior to be overridden.  <directive>CacheStoreNoCache</directive> On
712        tells the server to attempt to cache the resource even if it contains
713        no-store header values.  Resources requiring authorization will
714        <em>never</em> be cached.</p>
715
716     <example>
717       CacheStoreNoStore On
718     </example>
719
720     <note type="warning"><title>Warning:</title>
721        As described in RFC 2616, the no-store directive is intended to
722        "prevent the inadvertent release or retention of sensitive information
723        (for example, on backup tapes)."  Enabling this option could store
724        sensitive information in the cache.  You are hereby warned.
725     </note>
726 </usage>
727 <seealso><directive module="mod_cache">CacheIgnoreCacheControl</directive></seealso>
728 <seealso><directive module="mod_cache">CacheStorePrivate</directive></seealso>
729 </directivesynopsis>
730
731 <directivesynopsis>
732 <name>CacheLock</name>
733 <description>Enable the thundering herd lock.</description>
734 <syntax>CacheLock <var>on|off</var></syntax>
735 <default>CacheLock off</default>
736 <contextlist><context>server config</context><context>virtual host</context>
737 </contextlist>
738 <compatibility>Available in Apache 2.2.15 and later</compatibility>
739
740 <usage>
741   <p>The <directive>CacheLock</directive> directive enables the thundering herd lock
742   for the given URL space.</p>
743   
744   <p>In a minimal configuration the following directive is all that is needed to
745   enable the thundering herd lock in the default system temp directory.</p>
746
747   <example>
748     # Enable cache lock<br />
749     CacheLock on<br /><br />
750   </example>
751
752 </usage>
753 </directivesynopsis>
754
755 <directivesynopsis>
756 <name>CacheLockPath</name>
757 <description>Set the lock path directory.</description>
758 <syntax>CacheLockPath <var>directory</var></syntax>
759 <default>CacheLockPath /tmp/mod_cache-lock</default>
760 <contextlist><context>server config</context><context>virtual host</context>
761 </contextlist>
762     
763 <usage>
764   <p>The <directive>CacheLockPath</directive> directive allows you to specify the
765   directory in which the locks are created. By default, the system's temporary
766   folder is used. Locks consist of empty files that only exist for stale URLs
767   in flight, so is significantly less resource intensive than the traditional
768   disk cache.</p>
769
770 </usage>
771 </directivesynopsis>
772
773 <directivesynopsis>
774 <name>CacheLockMaxAge</name>
775 <description>Set the maximum possible age of a cache lock.</description>
776 <syntax>CacheLockMaxAge <var>integer</var></syntax>
777 <default>CacheLockMaxAge 5</default>
778 <contextlist><context>server config</context><context>virtual host</context>
779 </contextlist>
780     
781 <usage>
782   <p>The <directive>CacheLockMaxAge</directive> directive specifies the maximum
783   age of any cache lock.</p>
784   
785   <p>A lock older than this value in seconds will be ignored, and the next
786   incoming request will be given the opportunity to re-establish the lock.
787   This mechanism prevents a slow client taking an excessively long time to refresh
788   an entity.</p>
789   
790 </usage>
791 </directivesynopsis>
792
793 <directivesynopsis>
794   <name>CacheQuickHandler</name>
795   <description>Run the cache from the quick handler.</description>
796   <syntax>CacheQuickHandler <var>on|off</var></syntax>
797   <default>CacheQuickHandler on</default>
798   <contextlist><context>server config</context><context>virtual host</context>
799   </contextlist>
800
801   <usage>
802     <p>The <directive module="mod_cache">CacheQuickHandler</directive> directive
803     controls the phase in which the cache is handled.</p>
804
805     <p>In the default enabled configuration, the cache operates within the quick
806     handler phase. This phase short circuits the majority of server processing,
807     and represents the most performant mode of operation for a typical server.
808     The cache <strong>bolts onto</strong> the front of the server, and the
809     majority of server processing is avoided.</p>
810
811     <p>When disabled, the cache operates as a normal handler, and is subject to
812     the full set of phases when handling a server request. While this mode is
813     slower than the default, it allows the cache to be used in cases where full
814     processing is required, such as when content is subject to authorisation.</p>
815
816     <example>
817       # Run cache as a normal handler<br />
818       CacheQuickHandler off<br /><br />
819     </example>
820
821     <p>It is also possible, when the quick handler is disabled, for the
822     administrator to choose the precise location within the filter chain where
823     caching is to be performed, by adding the <strong>CACHE</strong> filter to
824     the chain.</p>
825
826     <example>
827       # Cache content before mod_include and mod_deflate<br />
828       CacheQuickHandler off<br />
829       AddOutputFilterByType CACHE;INCLUDES;DEFLATE text/html<br /><br />
830     </example>
831
832     <p>If the CACHE filter is specified more than once, the last instance will
833     apply.</p>
834
835   </usage>
836 </directivesynopsis>
837
838 <directivesynopsis>
839 <name>CacheHeader</name>
840 <description>Add an X-Cache header to the response.</description>
841 <syntax>CacheHeader <var>on|off</var></syntax>
842 <default>CacheHeader off</default>
843 <contextlist><context>server config</context>
844     <context>virtual host</context>
845     <context>directory</context>
846     <context>.htaccess</context>
847 </contextlist>
848 <compatibility>Available in Apache 2.3.9 and later</compatibility>
849   
850 <usage>
851   <p>When the <directive module="mod_cache">CacheHeader</directive> directive
852   is switched on, an <strong>X-Cache</strong> header will be added to the response
853   with the cache status of this response. If the normal handler is used, this
854   directive may appear within a <directive module="core">&lt;Directory&gt;</directive>
855   or <directive module="core">&lt;Location&gt;</directive> directive. If the quick
856   handler is used, this directive must appear within a server or virtual host
857   context, otherwise the setting will be ignored.</p>
858
859   <dl>
860     <dt><strong>HIT</strong></dt><dd>The entity was fresh, and was served from
861     cache.</dd>
862     <dt><strong>REVALIDATE</strong></dt><dd>The entity was stale, was successfully
863     revalidated and was served from cache.</dd>
864     <dt><strong>MISS</strong></dt><dd>The entity was fetched from the upstream
865       server and was not served from cache.</dd>
866   </dl>
867
868   <example>
869     # Enable the X-Cache header<br />
870     CacheHeader on<br />
871   </example>
872
873   <example>
874     X-Cache: HIT from localhost<br />
875   </example>
876
877 </usage>
878 </directivesynopsis>
879
880 <directivesynopsis>
881 <name>CacheDetailHeader</name>
882 <description>Add an X-Cache-Detail header to the response.</description>
883 <syntax>CacheDetailHeader <var>on|off</var></syntax>
884 <default>CacheDetailHeader off</default>
885 <contextlist><context>server config</context>
886       <context>virtual host</context>
887       <context>directory</context>
888       <context>.htaccess</context>
889 </contextlist>
890 <compatibility>Available in Apache 2.3.9 and later</compatibility>
891     
892 <usage>
893   <p>When the <directive module="mod_cache">CacheDetailHeader</directive> directive
894   is switched on, an <strong>X-Cache-Detail</strong> header will be added to the response
895   containing the detailed reason for a particular caching decision.</p>
896   
897   <p>It can be useful during development of cached RESTful services to have additional
898   information about the caching decision written to the response headers, so as to
899   confirm whether <code>Cache-Control</code> and other headers have been correctly
900   used by the service and client.</p>
901   
902   <p>If the normal handler is used, this directive may appear within a
903   <directive module="core">&lt;Directory&gt;</directive> or
904   <directive module="core">&lt;Location&gt;</directive> directive. If the quick handler
905   is used, this directive must appear within a server or virtual host context, otherwise
906   the setting will be ignored.</p>
907
908   <example>
909     # Enable the X-Cache-Detail header<br />
910     CacheDetailHeader on<br />
911   </example>
912
913   <example>
914     X-Cache-Detail: "conditional cache hit: entity refreshed" from localhost<br />
915   </example>
916
917 </usage>
918 </directivesynopsis>
919
920 </modulesynopsis>