2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
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
14 http://www.apache.org/licenses/LICENSE-2.0
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.
23 <modulesynopsis metafile="mod_cache.xml.meta">
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>
32 <note type="warning">This module should be used with care and
33 can be used to circumvent <directive
34 module="mod_authz_host">Allow</directive> and <directive
35 module="mod_authz_host">Deny</directive> directives. You
36 should not enable caching for any content to which you wish
37 to limit access by client host name, address or environment
40 <p><module>mod_cache</module> implements an <a
41 href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a> compliant HTTP
42 content cache that can be used to cache either local or proxied content.
43 <module>mod_cache</module> requires the services of one or more storage
44 management modules. One storage management module is included in
45 the base Apache distribution:</p>
47 <dt><module>mod_disk_cache</module></dt>
48 <dd>implements a disk based storage manager.</dd>
51 <p>Content is stored in and retrieved from the cache using URI based keys. Content with
52 access protection is not cached.</p>
53 <p>Further details, discussion, and examples, are provided in the
54 <a href="../caching.html">Caching Guide</a>.</p>
56 <seealso><a href="../caching.html">Caching Guide</a></seealso>
58 <section id="related"><title>Related Modules and Directives</title>
61 <module>mod_disk_cache</module>
64 <directive module="mod_disk_cache">CacheRoot</directive>
65 <directive module="mod_disk_cache">CacheDirLevels</directive>
66 <directive module="mod_disk_cache">CacheDirLength</directive>
67 <directive module="mod_disk_cache">CacheMinFileSize</directive>
68 <directive module="mod_disk_cache">CacheMaxFileSize</directive>
73 <section id="sampleconf"><title>Sample Configuration</title>
74 <example><title>Sample httpd.conf</title>
76 # Sample Cache Configuration<br />
78 LoadModule cache_module modules/mod_cache.so<br />
80 <IfModule mod_cache.c><br />
82 LoadModule disk_cache_module modules/mod_disk_cache.so<br />
83 <IfModule mod_disk_cache.c><br />
85 CacheRoot c:/cacheroot<br />
86 CacheEnable disk /<br />
87 CacheDirLevels 5<br />
88 CacheDirLength 3<br />
90 </IfModule> <br />
92 # When acting as a proxy, don't cache the list of security updates<br />
93 CacheDisable http://security.update.server/update-list/<br />
100 <name>CacheEnable</name>
101 <description>Enable caching of specified URLs using a specified storage
102 manager</description>
103 <syntax>CacheEnable <var>cache_type</var> <var>url-string</var></syntax>
104 <contextlist><context>server config</context><context>virtual host</context>
108 <p>The <directive>CacheEnable</directive> directive instructs
109 <module>mod_cache</module> to cache urls at or below
110 <var>url-string</var>. The cache storage manager is specified with the
111 <var>cache_type</var> argument.
112 <var>cache_type</var> <code>disk</code> instructs
113 <module>mod_cache</module> to use the disk based storage manager
114 implemented by <module>mod_disk_cache</module>.</p>
115 <p>In the event that the URL space overlaps between different
116 <directive>CacheEnable</directive> directives (as in the example below),
117 each possible storage manager will be run until the first one that
118 actually processes the request. The order in which the storage managers are
119 run is determined by the order of the <directive>CacheEnable</directive>
120 directives in the configuration file.</p>
122 <p>When acting as a forward proxy server, <var>url-string</var> can
123 also be used to specify remote sites and proxy protocols which
124 caching should be enabled for.</p>
127 # Cache proxied url's<br />
128 CacheEnable disk /<br /><br />
129 # Cache FTP-proxied url's<br />
130 CacheEnable disk ftp://<br /><br />
131 # Cache content from www.apache.org<br />
132 CacheEnable disk http://www.apache.org/<br />
135 <p> The <code>no-cache</code> environment variable can be set to
136 disable caching on a finer grained set of resources.</p>
139 <seealso><a href="../env.html">Environment Variables in Apache</a></seealso>
143 <name>CacheDisable</name>
144 <description>Disable caching of specified URLs</description>
145 <syntax>CacheDisable <var> url-string</var></syntax>
146 <contextlist><context>server config</context><context>virtual host</context>
150 <p>The <directive>CacheDisable</directive> directive instructs
151 <module>mod_cache</module> to <em>not</em> cache urls at or below
152 <var>url-string</var>.</p>
154 <example><title>Example</title>
155 CacheDisable /local_files
158 <p> The <code>no-cache</code> environment variable can be set to
159 disable caching on a finer grained set of resources.</p>
161 <seealso><a href="../env.html">Environment Variables in Apache</a></seealso>
164 <name>CacheMaxExpire</name>
165 <description>The maximum time in seconds to cache a document</description>
166 <syntax>CacheMaxExpire <var>seconds</var></syntax>
167 <default>CacheMaxExpire 86400 (one day)</default>
168 <contextlist><context>server config</context><context>virtual host</context>
172 <p>The <directive>CacheMaxExpire</directive> directive specifies the maximum number of
173 seconds for which cachable HTTP documents will be retained without checking the origin
174 server. Thus, documents will be out of date at most this number of seconds. This maximum
175 value is enforced even if an expiry date was supplied with the document.</p>
178 CacheMaxExpire 604800
184 <name>CacheMinExpire</name>
185 <description>The minimum time in seconds to cache a document</description>
186 <syntax>CacheMinExpire <var>seconds</var></syntax>
187 <default>CacheMinExpire 0</default>
188 <contextlist><context>server config</context><context>virtual host</context>
192 <p>The <directive>CacheMinExpire</directive> directive specifies the minimum number of
193 seconds for which cachable HTTP documents will be retained without checking the origin
194 server. This is only used if no valid expire time was supplied with the document.</p>
204 <name>CacheDefaultExpire</name>
205 <description>The default duration to cache a document when no expiry date is specified.</description>
206 <syntax>CacheDefaultExpire <var>seconds</var></syntax>
207 <default>CacheDefaultExpire 3600 (one hour)</default>
208 <contextlist><context>server config</context><context>virtual host</context>
212 <p>The <directive>CacheDefaultExpire</directive> directive specifies a default time,
213 in seconds, to cache a document if neither an expiry date nor last-modified date are provided
214 with the document. The value specified with the <directive>CacheMaxExpire</directive>
215 directive does <em>not</em> override this setting.</p>
218 CacheDefaultExpire 86400
224 <name>CacheIgnoreNoLastMod</name>
225 <description>Ignore the fact that a response has no Last Modified
226 header.</description>
227 <syntax>CacheIgnoreNoLastMod On|Off</syntax>
228 <default>CacheIgnoreNoLastMod Off</default>
229 <contextlist><context>server config</context><context>virtual host</context>
233 <p>Ordinarily, documents without a last-modified date are not cached.
234 Under some circumstances the last-modified date is removed (during
235 <module>mod_include</module> processing for example) or not provided
236 at all. The <directive>CacheIgnoreNoLastMod</directive> directive
237 provides a way to specify that documents without last-modified dates
238 should be considered for caching, even without a last-modified date.
239 If neither a last-modified date nor an expiry date are provided with
240 the document then the value specified by the
241 <directive>CacheDefaultExpire</directive> directive will be used to
242 generate an expiration date.</p>
245 CacheIgnoreNoLastMod On
251 <name>CacheIgnoreCacheControl</name>
252 <description>Ignore request to not serve cached content to client</description>
253 <syntax>CacheIgnoreCacheControl On|Off</syntax>
254 <default>CacheIgnoreCacheControl Off</default>
255 <contextlist><context>server config</context><context>virtual host</context>
259 <p>Ordinarily, requests containing a Cache-Control: no-cache or
260 Pragma: no-cache header value will not be served from the cache. The
261 <directive>CacheIgnoreCacheControl</directive> directive allows this
262 behavior to be overridden. <directive>CacheIgnoreCacheControl</directive>
263 On tells the server to attempt to serve the resource from the cache even
264 if the request contains no-cache header values. Resources requiring
265 authorization will <em>never</em> be cached.</p>
268 CacheIgnoreCacheControl On
271 <note type="warning"><title>Warning:</title>
272 This directive will allow serving from the cache even if the client has
273 requested that the document not be served from the cache. This might
274 result in stale content being served.
277 <seealso><directive module="mod_cache">CacheStorePrivate</directive></seealso>
278 <seealso><directive module="mod_cache">CacheStoreNoStore</directive></seealso>
282 <name>CacheIgnoreQueryString</name>
283 <description>Ignore query string when caching</description>
284 <syntax>CacheIgnoreQueryString On|Off</syntax>
285 <default>CacheIgnoreQueryString Off</default>
286 <contextlist><context>server config</context><context>virtual host</context>
290 <p>Ordinarily, requests with query string parameters are cached separately
291 for each unique query string. This is according to RFC 2616/13.9 done only
292 if an expiration time is specified. The
293 <directive>CacheIgnoreQueryString</directive> directive tells the cache to
294 cache requests even if no expiration time is specified, and to reply with
295 a cached reply even if the query string differs. From a caching point of
296 view the request is treated as if having no query string when this
297 directive is enabled.</p>
300 CacheIgnoreQueryString On
307 <name>CacheLastModifiedFactor</name>
308 <description>The factor used to compute an expiry date based on the
309 LastModified date.</description>
310 <syntax>CacheLastModifiedFactor <var>float</var></syntax>
311 <default>CacheLastModifiedFactor 0.1</default>
312 <contextlist><context>server config</context><context>virtual host</context>
316 <p>In the event that a document does not provide an expiry date but does
317 provide a last-modified date, an expiry date can be calculated based on
318 the time since the document was last modified. The
319 <directive>CacheLastModifiedFactor</directive> directive specifies a
320 <var>factor</var> to be used in the generation of this expiry date
321 according to the following formula:
323 <code>expiry-period = time-since-last-modified-date * <var>factor</var>
324 expiry-date = current-date + expiry-period</code>
326 For example, if the document was last modified 10 hours ago, and
327 <var>factor</var> is 0.1 then the expiry-period will be set to
328 10*0.1 = 1 hour. If the current time was 3:00pm then the computed
329 expiry-date would be 3:00pm + 1hour = 4:00pm.
331 If the expiry-period would be longer than that set by
332 <directive>CacheMaxExpire</directive>, then the latter takes
336 CacheLastModifiedFactor 0.5
342 <name>CacheIgnoreHeaders</name>
343 <description>Do not store the given HTTP header(s) in the cache.
345 <syntax>CacheIgnoreHeaders <var>header-string</var> [<var>header-string</var>] ...</syntax>
346 <default>CacheIgnoreHeaders None</default>
347 <contextlist><context>server config</context><context>virtual host</context>
351 <p>According to RFC 2616, hop-by-hop HTTP headers are not stored in
352 the cache. The following HTTP headers are hop-by-hop headers and thus
353 do not get stored in the cache in <em>any</em> case regardless of the
354 setting of <directive>CacheIgnoreHeaders</directive>:</p>
357 <li><code>Connection</code></li>
358 <li><code>Keep-Alive</code></li>
359 <li><code>Proxy-Authenticate</code></li>
360 <li><code>Proxy-Authorization</code></li>
361 <li><code>TE</code></li>
362 <li><code>Trailers</code></li>
363 <li><code>Transfer-Encoding</code></li>
364 <li><code>Upgrade</code></li>
367 <p><directive>CacheIgnoreHeaders</directive> specifies additional HTTP
368 headers that should not to be stored in the cache. For example, it makes
369 sense in some cases to prevent cookies from being stored in the cache.</p>
371 <p><directive>CacheIgnoreHeaders</directive> takes a space separated list
372 of HTTP headers that should not be stored in the cache. If only hop-by-hop
373 headers not should be stored in the cache (the RFC 2616 compliant
374 behaviour), <directive>CacheIgnoreHeaders</directive> can be set to
375 <code>None</code>.</p>
377 <example><title>Example 1</title>
378 CacheIgnoreHeaders Set-Cookie
381 <example><title>Example 2</title>
382 CacheIgnoreHeaders None
385 <note type="warning"><title>Warning:</title>
386 If headers like <code>Expires</code> which are needed for proper cache
387 management are not stored due to a
388 <directive>CacheIgnoreHeaders</directive> setting, the behaviour of
389 mod_cache is undefined.
395 <name>CacheStorePrivate</name>
396 <description>Attempt to cache responses that the server has marked as private</description>
397 <syntax>CacheStorePrivate On|Off</syntax>
398 <default>CacheStorePrivate Off</default>
399 <contextlist><context>server config</context><context>virtual host</context>
403 <p>Ordinarily, responses with Cache-Control: private header values will not
404 be stored in the cache. The <directive>CacheStorePrivate</directive>
405 directive allows this behavior to be overridden.
406 <directive>CacheStorePrivate</directive> On
407 tells the server to attempt to cache the resource even if it contains
408 private header values. Resources requiring authorization will
409 <em>never</em> be cached.</p>
415 <note type="warning"><title>Warning:</title>
416 This directive will allow caching even if the upstream server has
417 requested that the resource not be cached. This directive is only
418 ideal for a 'private' cache.
421 <seealso><directive module="mod_cache">CacheIgnoreCacheControl</directive></seealso>
422 <seealso><directive module="mod_cache">CacheStoreNoStore</directive></seealso>
426 <name>CacheStoreNoStore</name>
427 <description>Attempt to cache requests or responses that have been marked as no-store.</description>
428 <syntax>CacheStoreNoStore On|Off</syntax>
429 <default>CacheStoreNoStore Off</default>
430 <contextlist><context>server config</context><context>virtual host</context>
434 <p>Ordinarily, requests or responses with Cache-Control: no-store header
435 values will not be stored in the cache. The
436 <directive>CacheStoreNoCache</directive> directive allows this
437 behavior to be overridden. <directive>CacheStoreNoCache</directive> On
438 tells the server to attempt to cache the resource even if it contains
439 no-store header values. Resources requiring authorization will
440 <em>never</em> be cached.</p>
446 <note type="warning"><title>Warning:</title>
447 As described in RFC 2616, the no-store directive is intended to
448 "prevent the inadvertent release or retention of sensitive information
449 (for example, on backup tapes)." Enabling this option could store
450 sensitive information in the cache. You are hereby warned.
453 <seealso><directive module="mod_cache">CacheIgnoreCacheControl</directive></seealso>
454 <seealso><directive module="mod_cache">CacheStorePrivate</directive></seealso>