2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
6 Copyright 2002-2004 The Apache Software Foundation
8 Licensed under the Apache License, Version 2.0 (the "License");
9 you may not use this file except in compliance with the License.
10 You may obtain a copy of the License at
12 http://www.apache.org/licenses/LICENSE-2.0
14 Unless required by applicable law or agreed to in writing, software
15 distributed under the License is distributed on an "AS IS" BASIS,
16 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 See the License for the specific language governing permissions and
18 limitations under the License.
21 <modulesynopsis metafile="mod_mem_cache.xml.meta">
23 <name>mod_mem_cache</name>
24 <description>Content cache keyed to URIs</description>
25 <status>Experimental</status>
26 <sourcefile>mod_mem_cache.c</sourcefile>
27 <identifier>mem_cache_module</identifier>
31 This module is experimental. Documentation is still under
35 <p>This module <em>requires</em> the service of <module
36 >mod_cache</module>. It acts as a support module for <module
37 >mod_cache</module> and provides a memory based storage manager.
38 <module>mod_mem_cache</module> can be configured to operate in two
39 modes: caching open file descriptors or caching objects in heap storage.
40 <module>mod_mem_cache</module> is most useful when used to cache locally
41 generated content or to cache backend server content for <module
42 >mod_proxy</module> configured for <directive module="mod_proxy"
43 >ProxyPass</directive> (aka <dfn>reverse proxy</dfn>).</p>
45 <p>Content is stored in and retrieved from the cache using URI based
46 keys. Content with access protection is not cached.</p>
48 <seealso><module>mod_cache</module></seealso>
49 <seealso><module>mod_disk_cache</module></seealso>
52 <name>MCacheSize</name>
53 <description>The maximum amount of memory used by the cache in
55 <syntax>MCacheSize <var>KBytes</var></syntax>
56 <default>MCacheSize 100</default>
57 <contextlist><context>server config</context></contextlist>
60 <p>The <directive>MCacheSize</directive> directive sets the maximum
61 amount of memory to be used by the cache, in KBytes (1024-byte units).
62 If a new object needs to be inserted in the cache and the size of the
63 object is greater than the remaining memory, objects will be removed
64 until the new object can be cached. The object to be removed is
65 selected using the algorithm specified by <directive
66 module="mod_mem_cache">MCacheRemovalAlgorithm</directive>.</p>
68 <example><title>Example</title>
72 <note><title>Note</title>
73 <p>The <directive>MCacheSize</directive> value must be greater than
74 the value specified by the <directive module="mod_mem_cache"
75 >MCacheMaxObjectSize</directive> directive.</p>
81 <name>MCacheMaxObjectCount</name>
82 <description>The maximum number of objects allowed to be placed in the
84 <syntax>MCacheMaxObjectCount <var>value</var></syntax>
85 <default>MCacheMaxObjectCount 1009</default>
86 <contextlist><context>server config</context></contextlist>
89 <p>The <directive>MCacheMaxObjectCount</directive> directive sets the
90 maximum number of objects to be cached. The value is used to create the
91 open hash table. If a new object needs to be inserted in the cache and
92 the maximum number of objects has been reached, an object will be
93 removed to allow the new object to be cached. The object to be removed
94 is selected using the algorithm specified by <directive
95 module="mod_mem_cache">MCacheRemovalAlgorithm</directive>.</p>
97 <example><title>Example</title>
98 MCacheMaxObjectCount 13001
104 <name>MCacheMinObjectSize</name>
105 <description>The minimum size (in bytes) of a document to be allowed in the
107 <syntax>MCacheMinObjectSize <var>bytes</var></syntax>
108 <default>MCacheMinObjectSize 0</default>
109 <contextlist><context>server config</context></contextlist>
112 <p>The <directive>MCacheMinObjectSize</directive> directive sets the
113 minimum size in bytes of a document for it to be considered
116 <example><title>Example</title>
117 MCacheMinObjectSize 10000
123 <name>MCacheMaxObjectSize</name>
124 <description>The maximum size (in bytes) of a document allowed in the
126 <syntax>MCacheMaxObjectSize <var>bytes</var></syntax>
127 <default>MCacheMaxObjectSize 10000</default>
128 <contextlist><context>server config</context></contextlist>
131 <p>The <directive>MCacheMaxObjectSize</directive> directive sets the
132 maximum allowable size, in bytes, of a document for it to be considered
135 <example><title>Example</title>
136 MCacheMaxObjectSize 6400000
139 <note><title>Note</title>
140 <p>The value of <directive>MCacheMaxObjectSize</directive> must be
141 greater than the value specified by the <directive
142 module="mod_mem_cache">MCacheMinObjectSize</directive> directive.</p>
148 <name>MCacheRemovalAlgorithm</name>
149 <description>The algorithm used to select documents for removal from the
151 <syntax>MCacheRemovalAlgorithm LRU|GDSF</syntax>
152 <default>MCacheRemovalAlgorithm GDSF</default>
153 <contextlist><context>server config</context></contextlist>
156 <p>The <directive>MCacheRemovalAlgorithm</directive> directive specifies
157 the algorithm used to select documents for removal from the cache.
158 Two choices are available:</p>
161 <dt><code>LRU</code> (Least Recently Used)</dt>
162 <dd><code>LRU</code> removes the documents that have not been accessed
163 for the longest time.</dd>
165 <dt><code>GDSF</code> (GreadyDual-Size)</dt>
166 <dd><code>GDSF</code> assigns a priority to cached documents based
167 on the cost of a cache miss and the size of the document. Documents
168 with the lowest priority are removed first.</dd>
171 <example><title>Example</title>
172 MCacheRemovalAlgorithm GDSF<br />
173 MCacheRemovalAlgorithm LRU
179 <name>MCacheMaxStreamingBuffer</name>
180 <description>Maximum amount of a streamed response to buffer in memory
181 before declaring the response uncacheable</description>
182 <syntax>MCacheMaxStreamingBuffer <var>size_in_bytes</var></syntax>
183 <default>MCacheMaxStreamingBuffer the smaller of 100000 or MCacheMaxObjectSize</default>
184 <contextlist><context>server config</context>
188 <p>The <directive>MCacheMaxStreamingBuffer</directive> directive
189 specifies the maximum number of bytes of a streamed response to
190 buffer before deciding that the response is too big to cache.
191 A streamed response is one in which the entire content is not
192 immediately available and in which the <code>Content-Length</code>
193 may not be known. Sources of streaming responses include proxied
194 responses and the output of CGI scripts. By default, a streamed
195 response will <em>not</em> be cached unless it has a
196 <code>Content-Length</code> header. The reason for this is to
197 avoid using a large amount of memory to buffer a partial response
198 that might end up being too large to fit in the cache.
199 The <directive>MCacheMaxStreamingBuffer</directive> directive allows
200 buffering of streamed responses that don't contain a
201 <code>Content-Length</code> up to the specified maximum amount of
202 space. If the maximum buffer space is reached, the buffered
203 content is discarded and the attempt to cache is abandoned.</p>
205 <note><title>Note:</title>
206 <p>Using a nonzero value for <directive>MCacheMaxStreamingBuffer</directive>
207 will not delay the transmission of the response to the client.
208 As soon as <module>mod_mem_cache</module> copies a block of streamed
209 content into a buffer, it sends the block on to the next output
210 filter for delivery to the client.</p>
214 # Enable caching of streamed responses up to 64KB:<br />
215 MCacheMaxStreamingBuffer 65536