2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
7 <description>Content cache keyed to URIs.</description>
8 <status>Experimental</status>
9 <sourcefile>mod_cache.c</sourcefile>
10 <identifier>cache_module</identifier>
14 This module is experimental. Documentation is still under development...
16 <p>mod_cache implements an RFC 2616 compliant HTTP content
17 cache that can be used to cache either local or proxied content.
18 mod_cache requires the services of one or more storage
19 management modules. Two storage management modules are included in
20 the base Apache distribution:</p>
22 <dt><module>mod_disk_cache</module></dt>
23 <dd>implements a disk based storage manager for use with <module>mod_proxy</module></dd>
24 <dt><module>mod_mem_cache</module></dt>
25 <dd>implements an in-memory based storage manager. mod_mem_cache
26 can be configured to operate in two modes: caching open file
27 descriptors or caching objects in heap storage. <em><module>mod_mem_cache</module></em>
28 is most useful when used to cache locally generated content or to cache
29 backend server content for mod_proxy configured for ProxyPass (aka <em>reverse proxy</em>)</dd>
31 <p>Content stored and retrived keyed to the URL. Content with
32 access protections is not cached.</p>
35 <section id="related"><title>Related Modules and Directives</title>
38 <module>mod_disk_cache</module>
39 <module>mod_mem_cache</module>
42 <directive module="mod_disk_cache">CacheRoot</directive>
43 <directive module="mod_disk_cache">CacheSize</directive>
44 <directive module="mod_disk_cache">CacheGcInterval</directive>
45 <directive module="mod_disk_cache">CacheDirLevels</directive>
46 <directive module="mod_disk_cache">CacheDirLength</directive>
47 <directive module="mod_disk_cache">CacheExpiryCheck</directive>
48 <directive module="mod_disk_cache">CacheMinFileSize</directive>
49 <directive module="mod_disk_cache">CacheMaxFileSize</directive>
50 <directive module="mod_disk_cache">CacheTimeMargin</directive>
51 <directive module="mod_disk_cache">CacheGcDaily</directive>
52 <directive module="mod_disk_cache">CacheGcUnused</directive>
53 <directive module="mod_disk_cache">CacheGcClean</directive>
54 <directive module="mod_disk_cache">CacheGcMemUsage</directive>
55 <directive module="mod_mem_cache">MCacheSize</directive>
56 <directive module="mod_mem_cache">MCacheMaxObjectCount</directive>
57 <directive module="mod_mem_cache">MCacheMinObjectSize</directive>
58 <directive module="mod_mem_cache">MCacheMaxObjectSize</directive>
59 <directive module="mod_mem_cache">MCacheRemovalAlgorithm</directive>
64 <section><title>Sample Configuration</title>
65 <example><title>Sample httpd.conf</title>
67 # Sample Cache Configuration <br />
69 LoadModule cache_module modules/mod_cache.so <br />
70 <IfModule mod_cache.c> <br />
72 #LoadModule disk_cache_module modules/mod_disk_cache.so <br />
73 <IfModule mod_disk_cache.c> <br />
74 CacheRoot c:/cacheroot <br />
76 CacheEnable disk / <br />
77 CacheDirLevels 5 <br />
78 CacheDirLength 3 <br />
79 </IfModule> <br />
81 LoadModule mem_cache_module modules/mod_mem_cache.so <br />
82 <IfModule mod_mem_cache.c> <br />
83 MCacheEnable mem / <br />
84 MCacheSize 4096 <br />
85 MCacheMaxObjectCount 100 <br />
86 MCacheMinObjectSize 1 <br />
87 MCacheMaxObjectSize 2048 <br />
88 </IfModule> <br />
90 </IfModule> <br />
95 <name>CacheEnable</name>
96 <description>Enable caching specified URLs in a specified storage manager</description>
97 <syntax>CacheEnable <em>cache_type </em><em> url-string</em></syntax>
98 <contextlist><context>server config</context></contextlist>
101 <p>The <directive>CacheEnable</directive> directive instructs
102 mod_cache to cache urls at or below <em>url-string</em>.
103 The cache store is specified with the <em>cache_type</em> argument.
104 <em>cache_type </em> <em> mem</em> instructs mod_cache to use the
105 in-memory cache storage manager implemented by <em>mod_mem_cache</em>.
106 <em>cache_type </em> <em> disk</em> instructs mod_cache to use the
107 cache storage manager implemented by <em>mod_disk_cache </em>. </p>
110 CacheEnable disk / <br />
111 CacheEnable mem /manual <br />
112 CacheEnable fd /images <br />
119 <name>CacheDisable</name>
120 <description>Disable caching of specified URLs by specified storage manager</description>
121 <syntax>CacheDisable <em>cache_type </em> <em> url-string</em></syntax>
122 <contextlist><context>server config</context></contextlist>
125 <p>The <directive>CacheDisable</directive> directive instructs
126 mod_cache to <em>not</em> cache urls at or above <em>url-string</em>.</p>
128 <example><title>Example</title>
129 CacheDisable disk /local_files
135 <name>CacheMaxExpire</name>
136 <description>The maximum time in seconds to cache a document</description>
137 <syntax>CacheMaxExpire <em>seconds</em></syntax>
138 <default>CacheMaxExpire 86400 (one day)</default>
139 <contextlist><context>server config</context></contextlist>
142 <p>The maximum time in seconds to cache a document. The <directive>CacheMaxExpire</directive>
143 takes precedence over the <em>Expire</em> field from the header.</p>
145 CacheMaxExpire 604800
150 <name>CacheDefaultExpire</name>
151 <syntax>CacheDefaultExpire <em>seconds</em></syntax>
152 <default>CacheDefaultExpire 3600 (one hour)</default>
153 <contextlist><context>server config</context></contextlist>
156 <p>The default time in seconds to cache a document if the page does not have
157 an expiry date in the <em>Expires</em> field.</p>
159 CacheDefaultExpire 86400
165 <name>CacheIgnoreNoLastMod</name>
166 <description>Ignore responses where there is no Last Modified Header</description>
167 <syntax>CacheIgnoreNoLastMod</syntax>
168 <contextlist><context>server config</context></contextlist>
171 <p>Ignore responses where there is no Last Modified Header</p>
180 <name>CacheIgnoreCacheControl</name>
181 <description>Ignore requests from the client for uncached content</description>
182 <syntax>CacheIgnoreCacheControl</syntax>
183 <contextlist><context>server config</context></contextlist>
186 <p>Ignore requests from the client for uncached content</p>
195 <name>CacheLastModifiedFactor</name>
196 <description>The factor used to estimate the Expires date from the LastModified date</description>
197 <syntax>CacheLastModifiedFactor <em>float</em></syntax>
198 <default>CacheLastModifiedFactor 0.1</default>
199 <contextlist><context>server config</context></contextlist>
202 <p>The factor used to estimate the Expires date from the LastModified date.</p>
205 CacheLastModifiedFactor 0.5
211 <name>CacheForceCompletion</name>
212 <description>Percentage of download to arrive for the cache to force complete transfert</description>
213 <syntax>CacheForceCompletion <em>Percentage</em></syntax>
214 <default>CacheForceCompletion 60</default>
215 <contextlist><context>server config</context></contextlist>
218 <p>Percentage of download to arrive for the cache to force complete transfert.</p>
221 CacheForceCompletion 80
223 <note type="warning">
224 This feature is currently <em>not</em> implemented.
230 <name>CacheMaxStreamingBuffer</name>
231 <description>Maximum amount of a streamed response to buffer in memory before declaring the response uncacheable</description>
232 <syntax>CacheMaxStreamingBuffer <em>size_in_bytes</em></syntax>
233 <default>CacheMaxStreamingBuffer 0</default>
234 <contextlist><context>server config</context></contextlist>
237 <p>Maximum number of bytes of a streamed response (i.e., a response where the entire content is not available all at once, such as a proxy or CGI response) to buffer before deciding if the response is cacheable. By default, a streamed response will <em>not</em> be cached unless it has a Content-Length header. The reason for this is to avoid using a large amount of memory to buffer a partial response that might end up being too large to fit in the cache anyway. To enable caching of streamed responses, use CacheMaxStreamingBuffer to specify the maximum amount of buffer space to use per request.</p>
238 <p>Note: Using a nonzero value for CacheMaxStreamingBuffer will not delay the transmission of the response to the client. As soon as mod_cache copies a
239 block of streamed content into a buffer, it sends the block on to the next
240 output filter for delivery to the client.</p>
243 # Enable caching of streamed responses up to 64KB:
244 CacheMaxStreamingBuffer 65536