]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_cache.xml
a few new translations and up-to-date patches
[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 <!-- $Revision: 1.17 $ -->
5
6 <!--
7  Copyright 2002-2004 The Apache Software Foundation
8
9  Licensed under the Apache License, Version 2.0 (the "License");
10  you may not use this file except in compliance with the License.
11  You may obtain a copy of the License at
12
13      http://www.apache.org/licenses/LICENSE-2.0
14
15  Unless required by applicable law or agreed to in writing, software
16  distributed under the License is distributed on an "AS IS" BASIS,
17  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  See the License for the specific language governing permissions and
19  limitations under the License.
20 -->
21
22 <modulesynopsis metafile="mod_cache.xml.meta">
23
24 <name>mod_cache</name>
25 <description>Content cache keyed to URIs.</description>
26 <status>Experimental</status>
27 <sourcefile>mod_cache.c</sourcefile>
28 <identifier>cache_module</identifier>
29
30 <summary>
31     <note type="warning">
32       This module is experimental. Documentation is still under development...
33     </note>
34
35     <p><module>mod_cache</module> implements an <a
36     href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a> compliant HTTP
37     content cache that can be used to cache either local or proxied content.
38     <module>mod_cache</module> requires the services of one or more storage
39     management modules. Two storage management modules are included in
40     the base Apache distribution:</p>
41     <dl>
42     <dt><module>mod_disk_cache</module></dt>
43     <dd>implements a disk based storage manager.</dd>
44
45     <dt><module>mod_mem_cache</module></dt>
46     <dd>implements a memory based storage manager. 
47     <module>mod_mem_cache</module> can be configured to operate in two
48     modes: caching open file descriptors or caching objects in heap storage.
49     <module>mod_mem_cache</module> can be used to cache locally generated content
50     or to cache backend server content for <module>mod_proxy</module> when
51     configured using <directive module="mod_proxy">ProxyPass</directive>
52     (aka <dfn>reverse proxy</dfn>)</dd>
53     </dl>
54
55     <p>Content is stored in and retrieved from the cache using URI based keys. Content with
56     access protection is not cached.</p>
57 </summary>
58
59 <section id="related"><title>Related Modules and Directives</title>
60     <related>
61       <modulelist>
62         <module>mod_disk_cache</module>
63         <module>mod_mem_cache</module>
64       </modulelist>
65       <directivelist>
66         <directive module="mod_disk_cache">CacheRoot</directive>
67         <directive module="mod_disk_cache">CacheSize</directive>
68         <directive module="mod_disk_cache">CacheGcInterval</directive>
69         <directive module="mod_disk_cache">CacheDirLevels</directive>
70         <directive module="mod_disk_cache">CacheDirLength</directive>
71         <directive module="mod_disk_cache">CacheExpiryCheck</directive>
72         <directive module="mod_disk_cache">CacheMinFileSize</directive>
73         <directive module="mod_disk_cache">CacheMaxFileSize</directive>
74         <directive module="mod_disk_cache">CacheTimeMargin</directive>
75         <directive module="mod_disk_cache">CacheGcDaily</directive>
76         <directive module="mod_disk_cache">CacheGcUnused</directive>
77         <directive module="mod_disk_cache">CacheGcClean</directive>
78         <directive module="mod_disk_cache">CacheGcMemUsage</directive>
79         <directive module="mod_mem_cache">MCacheSize</directive>
80         <directive module="mod_mem_cache">MCacheMaxObjectCount</directive>
81         <directive module="mod_mem_cache">MCacheMinObjectSize</directive>
82         <directive module="mod_mem_cache">MCacheMaxObjectSize</directive>
83         <directive module="mod_mem_cache">MCacheRemovalAlgorithm</directive>
84         <directive module="mod_mem_cache">MCacheMaxStreamingBuffer</directive>
85       </directivelist>
86     </related>
87 </section>
88
89 <section id="sampleconf"><title>Sample Configuration</title>
90     <example><title>Sample httpd.conf</title>
91       #<br />
92       # Sample Cache Configuration<br />
93       #<br />
94       LoadModule cache_module modules/mod_cache.so<br />
95       <br />
96       &lt;IfModule mod_cache.c&gt;<br />
97       <indent>
98         #LoadModule disk_cache_module modules/mod_disk_cache.so<br />
99         &lt;IfModule mod_disk_cache.c&gt;<br />
100         <indent>
101           CacheRoot c:/cacheroot<br />
102           CacheSize 256<br />
103           CacheEnable disk  /<br />
104           CacheDirLevels 5<br />
105           CacheDirLength 3<br />
106         </indent>
107         &lt;/IfModule&gt; <br />
108         <br />
109         LoadModule mem_cache_module modules/mod_mem_cache.so<br />
110         &lt;IfModule mod_mem_cache.c&gt;<br />
111         <indent>
112           CacheEnable mem  /<br />
113           MCacheSize 4096<br />
114           MCacheMaxObjectCount 100<br />
115           MCacheMinObjectSize 1<br />
116           MCacheMaxObjectSize 2048<br />
117         </indent>
118         &lt;/IfModule&gt;<br />
119       </indent>
120       &lt;/IfModule&gt;
121     </example>
122 </section>
123
124 <directivesynopsis>
125 <name>CacheEnable</name>
126 <description>Enable caching of specified URLs using a specified storage
127 manager</description>
128 <syntax>CacheEnable <var>cache_type</var> <var>url-string</var></syntax>
129 <contextlist><context>server config</context><context>virtual host</context>
130 </contextlist>
131
132 <usage>
133     <p>The <directive>CacheEnable</directive> directive instructs
134     <module>mod_cache</module> to cache urls at or below
135     <var>url-string</var>. The cache storage manager is specified with the
136     <var>cache_type</var> argument. <var>cache_type</var> <code> mem</code>
137     instructs <module>mod_cache</module> to use the memory based storage
138     manager implemented by <module>mod_mem_cache</module>. 
139     <var>cache_type</var> <code>disk</code> instructs
140     <module>mod_cache</module> to use the disk based storage manager
141     implemented by <module>mod_disk_cache</module>.
142     <var>cache_type</var> <code>fd</code> instructs
143     <module>mod_cache</module> to use the file descriptor cache implemented
144     by <module>mod_mem_cache</module>.</p>
145     <p>In the event that the URL space overlaps between different
146     <directive>CacheEnable</directive> directives (as in the example below),
147     each possible storage manager will be run until the first one that
148     actually processes the request. The order in which the storage managers are
149     run is determined by the order of the <directive>CacheEnable</directive>
150     directives in the configuration file.</p>
151
152     <example>
153       CacheEnable  mem   /manual<br />
154       CacheEnable  fd    /images<br />
155       CacheEnable  disk  /<br />
156     </example>
157 </usage>
158 </directivesynopsis>
159
160 <directivesynopsis>
161 <name>CacheDisable</name>
162 <description>Disable caching of specified URLs</description>
163 <syntax>CacheDisable <var> url-string</var></syntax>
164 <contextlist><context>server config</context><context>virtual host</context>
165 </contextlist>
166
167 <usage>
168     <p>The <directive>CacheDisable</directive> directive instructs
169     <module>mod_cache</module> to <em>not</em> cache urls at or below
170     <var>url-string</var>.</p>
171
172     <example><title>Example</title>
173       CacheDisable /local_files
174     </example>
175 </usage>
176
177 </directivesynopsis>
178 <directivesynopsis>
179 <name>CacheMaxExpire</name>
180 <description>The maximum time in seconds to cache a document</description>
181 <syntax>CacheMaxExpire <var>seconds</var></syntax>
182 <default>CacheMaxExpire 86400 (one day)</default>
183 <contextlist><context>server config</context><context>virtual host</context>
184 </contextlist>
185
186 <usage>
187     <p>The <directive>CacheMaxExpire</directive> directive specifies the maximum number of
188     seconds for which cachable HTTP documents will be retained without checking the origin
189     server. Thus, documents will be out of date at most this number of seconds. This maximum
190     value is enforced even if an expiry date was supplied with the document.</p>
191
192     <example>
193       CacheMaxExpire 604800
194     </example>
195 </usage>
196 </directivesynopsis>
197
198 <directivesynopsis>
199 <name>CacheDefaultExpire</name>
200 <description>The default duration to cache a document when no expiry date is specified.</description>
201 <syntax>CacheDefaultExpire <var>seconds</var></syntax>
202 <default>CacheDefaultExpire 3600 (one hour)</default>
203 <contextlist><context>server config</context><context>virtual host</context>
204 </contextlist>
205
206 <usage>
207     <p>The <directive>CacheDefaultExpire</directive> directive specifies a default time,
208     in seconds, to cache a document if neither an expiry date nor last-modified date are provided
209     with the document. The value specified with the <directive>CacheMaxExpire</directive>
210     directive does <em>not</em> override this setting.</p>
211
212     <example>
213       CacheDefaultExpire 86400
214     </example>
215 </usage>
216 </directivesynopsis>
217
218 <directivesynopsis>
219 <name>CacheIgnoreNoLastMod</name>
220 <description>Ignore the fact that a response has no Last Modified
221 header.</description>
222 <syntax>CacheIgnoreNoLastMod On|Off</syntax>
223 <default>CacheIgnoreNoLastMod Off</default>
224 <contextlist><context>server config</context><context>virtual host</context>
225 </contextlist>
226
227 <usage>
228     <p>Ordinarily, documents without a last-modified date are not cached.
229     Under some circumstances the last-modified date is removed (during
230     <module>mod_include</module> processing for example) or not provided
231     at all. The <directive>CacheIgnoreNoLastMod</directive> directive
232     provides a way to specify that documents without last-modified dates
233     should be considered for caching, even without a last-modified date.
234     If neither a last-modified date nor an expiry date are provided with
235     the document then the value specified by the
236     <directive>CacheDefaultExpire</directive> directive will be used to
237     generate an expiration date.</p>
238
239     <example>
240       CacheIgnoreNoLastMod On
241     </example>
242 </usage>
243 </directivesynopsis>
244
245 <directivesynopsis>
246 <name>CacheIgnoreCacheControl</name>
247 <description>Ignore the fact that the client requested the content not be
248 cached.</description>
249 <syntax>CacheIgnoreCacheControl On|Off</syntax>
250 <default>CacheIgnoreCacheControl Off</default>
251 <contextlist><context>server config</context><context>virtual host</context>
252 </contextlist>
253
254 <usage>
255     <p>Ordinarily, documents with no-cache or no-store header values will not be stored in the cache.
256     The <directive>CacheIgnoreCacheControl</directive> directive allows this behavior to be overridden.
257     <directive>CacheIgnoreCacheControl</directive> On tells the server to attempt to cache the document
258     even if it contains no-cache or no-store header values. Documents requiring authorization will
259     <em>never</em> be cached.</p>
260
261     <example>
262       CacheIgnoreCacheControl On
263     </example>
264 </usage>
265 </directivesynopsis>
266
267 <directivesynopsis>
268 <name>CacheLastModifiedFactor</name>
269 <description>The factor used to compute an expiry date based on the
270 LastModified date.</description>
271 <syntax>CacheLastModifiedFactor <var>float</var></syntax>
272 <default>CacheLastModifiedFactor 0.1</default>
273 <contextlist><context>server config</context><context>virtual host</context>
274 </contextlist>
275
276 <usage>
277     <p>In the event that a document does not provide an expiry date but does
278     provide a last-modified date, an expiry date can be calculated based on
279     the time since the document was last modified. The
280     <directive>CacheLastModifiedFactor</directive> directive specifies a
281     <var>factor</var> to be used in the generation of this expiry date
282     according to the following formula:
283
284     <code>expiry-period = time-since-last-modified-date * <var>factor</var>
285     expiry-date = current-date + expiry-period</code>
286
287     For example, if the document was last modified 10 hours ago, and
288     <var>factor</var> is 0.1 then the expiry-period will be set to
289     10*0.1 = 1 hour. If the current time was 3:00pm then the computed
290     expiry-date would be 3:00pm + 1hour = 4:00pm.
291
292     If the expiry-period would be longer than that set by
293     <directive>CacheMaxExpire</directive>, then the latter takes
294     precedence.</p>
295
296     <example>
297       CacheLastModifiedFactor 0.5
298     </example>
299 </usage>
300 </directivesynopsis>
301
302 <directivesynopsis>
303 <name>CacheForceCompletion</name>
304 <description>Percentage of document served, after which the server
305 will complete caching the file even if the request is cancelled.</description>
306 <syntax>CacheForceCompletion <var>Percentage</var></syntax>
307 <default>CacheForceCompletion 60</default>
308 <contextlist><context>server config</context><context>virtual host</context>
309 </contextlist>
310
311 <usage>
312     <p>Ordinarily, if a request is cancelled while the response is being
313     cached and delivered to the client the processing of the response will
314     stop and the cache entry will be removed. The
315     <directive>CacheForceCompletion</directive> directive specifies a
316     threshold beyond which the document will continue to be cached to
317     completion, even if the request is cancelled.</p>
318
319     <p>The threshold is a percentage specified as a value between
320     <code>1</code> and <code>100</code>. A value of <code>0</code>
321     specifies that the default be used. A value of <code>100</code>
322     will only cache documents that are served in their entirety. A value
323     between 60 and 90 is recommended.</p>
324
325     <example>
326       CacheForceCompletion 80
327     </example>
328
329     <note type="warning"><title>Note:</title>
330       This feature is currently <em>not</em> implemented.
331     </note>
332 </usage>
333 </directivesynopsis>
334
335 </modulesynopsis>