1<?xml version="1.0" encoding="ISO-8859-1"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!-- 4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 5 This file is generated from xml source: DO NOT EDIT 6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 7 --> 8<title>mod_mem_cache - Apache HTTP Server</title> 9<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> 10<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> 11<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="/style/css/prettify.css" /> 12<script src="/style/scripts/prettify.js" type="text/javascript"> 13</script> 14 15<link href="/images/favicon.ico" rel="shortcut icon" /></head> 16<body> 17<div id="page-header"> 18<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p> 19<p class="apache">Apache HTTP Server Version 2.2</p> 20<img alt="" src="/images/feather.gif" /></div> 21<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div> 22<div id="path"> 23<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Modules</a></div> 24<div id="page-content"> 25<div id="preamble"><h1>Apache Module mod_mem_cache</h1> 26<div class="toplang"> 27<p><span>Available Languages: </span><a href="/en/mod/mod_mem_cache.html" title="English"> en </a> | 28<a href="/ja/mod/mod_mem_cache.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 29<a href="/ko/mod/mod_mem_cache.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p> 30</div> 31<table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Content cache keyed to URIs</td></tr> 32<tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr> 33<tr><th><a href="module-dict.html#ModuleIdentifier">Module�Identifier:</a></th><td>mem_cache_module</td></tr> 34<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_mem_cache.c</td></tr></table> 35<h3>Summary</h3> 36 37 <p>This module <em>requires</em> the service of <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code>. It acts as a support module for <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> and provides a memory based storage manager. 38 <code class="module"><a href="/mod/mod_mem_cache.html">mod_mem_cache</a></code> can be configured to operate in two 39 modes: caching open file descriptors or caching objects in heap storage. 40 <code class="module"><a href="/mod/mod_mem_cache.html">mod_mem_cache</a></code> is most useful when used to cache locally 41 generated content or to cache backend server content for <code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code> configured for <code class="directive"><a href="/mod/mod_proxy.html#proxypass">ProxyPass</a></code> (aka <dfn>reverse proxy</dfn>).</p> 42 43 <p>Content is stored in and retrieved from the cache using URI based 44 keys. Content with access protection is not cached.</p> 45 46 <div class="note"><h3>Note</h3>In most cases <code class="module"><a href="/mod/mod_disk_cache.html">mod_disk_cache</a></code> 47 should be the preferred choice. This is explained further in the <a href="/caching.html#inmemory">Caching Guide</a>. In particular, 48 this module's cache is <em>per-process</em>, which can be partially 49 mitigated by configuring threaded MPMs to use fewer child processes 50 via configuration of larger values for <code class="directive"><a href="/mod/mpm_common.html#threadsperchild">ThreadsPerChild</a></code>. This module's cache is 51 also limited to storing a single variant (see HTTP Vary: header) of each 52 resource in the cache.</div> 53</div> 54<div id="quickview"><h3 class="directives">Directives</h3> 55<ul id="toc"> 56<li><img alt="" src="/images/down.gif" /> <a href="#mcachemaxobjectcount">MCacheMaxObjectCount</a></li> 57<li><img alt="" src="/images/down.gif" /> <a href="#mcachemaxobjectsize">MCacheMaxObjectSize</a></li> 58<li><img alt="" src="/images/down.gif" /> <a href="#mcachemaxstreamingbuffer">MCacheMaxStreamingBuffer</a></li> 59<li><img alt="" src="/images/down.gif" /> <a href="#mcacheminobjectsize">MCacheMinObjectSize</a></li> 60<li><img alt="" src="/images/down.gif" /> <a href="#mcacheremovalalgorithm">MCacheRemovalAlgorithm</a></li> 61<li><img alt="" src="/images/down.gif" /> <a href="#mcachesize">MCacheSize</a></li> 62</ul> 63<h3>See also</h3> 64<ul class="seealso"> 65<li><code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code></li> 66<li><code class="module"><a href="/mod/mod_disk_cache.html">mod_disk_cache</a></code></li> 67</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> 68 69<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 70<div class="directive-section"><h2><a name="MCacheMaxObjectCount" id="MCacheMaxObjectCount">MCacheMaxObjectCount</a> <a name="mcachemaxobjectcount" id="mcachemaxobjectcount">Directive</a></h2> 71<table class="directive"> 72<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The maximum number of objects allowed to be placed in the 73cache</td></tr> 74<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>MCacheMaxObjectCount <var>value</var></code></td></tr> 75<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>MCacheMaxObjectCount 1009</code></td></tr> 76<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr> 77<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 78<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_mem_cache</td></tr> 79</table> 80 <p>The <code class="directive">MCacheMaxObjectCount</code> directive sets the 81 maximum number of objects to be cached. The value is used to create the 82 open hash table. If a new object needs to be inserted in the cache and 83 the maximum number of objects has been reached, an object will be 84 removed to allow the new object to be cached. The object to be removed 85 is selected using the algorithm specified by <code class="directive"><a href="#mcacheremovalalgorithm">MCacheRemovalAlgorithm</a></code>.</p> 86 87 <div class="example"><h3>Example</h3><p><code> 88 MCacheMaxObjectCount 13001 89 </code></p></div> 90 91</div> 92<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 93<div class="directive-section"><h2><a name="MCacheMaxObjectSize" id="MCacheMaxObjectSize">MCacheMaxObjectSize</a> <a name="mcachemaxobjectsize" id="mcachemaxobjectsize">Directive</a></h2> 94<table class="directive"> 95<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The maximum size (in bytes) of a document allowed in the 96cache</td></tr> 97<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>MCacheMaxObjectSize <var>bytes</var></code></td></tr> 98<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>MCacheMaxObjectSize 10000</code></td></tr> 99<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr> 100<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 101<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_mem_cache</td></tr> 102</table> 103 <p>The <code class="directive">MCacheMaxObjectSize</code> directive sets the 104 maximum allowable size, in bytes, of a document for it to be considered 105 cacheable.</p> 106 107 <div class="example"><h3>Example</h3><p><code> 108 MCacheMaxObjectSize 6400000 109 </code></p></div> 110 111 <div class="note"><h3>Note</h3> 112 <p>The value of <code class="directive">MCacheMaxObjectSize</code> must be 113 greater than the value specified by the <code class="directive"><a href="#mcacheminobjectsize">MCacheMinObjectSize</a></code> directive.</p> 114 </div> 115 116</div> 117<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 118<div class="directive-section"><h2><a name="MCacheMaxStreamingBuffer" id="MCacheMaxStreamingBuffer">MCacheMaxStreamingBuffer</a> <a name="mcachemaxstreamingbuffer" id="mcachemaxstreamingbuffer">Directive</a></h2> 119<table class="directive"> 120<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maximum amount of a streamed response to buffer in memory 121before declaring the response uncacheable</td></tr> 122<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>MCacheMaxStreamingBuffer <var>size_in_bytes</var></code></td></tr> 123<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>MCacheMaxStreamingBuffer the smaller of 100000 or MCacheMaxObjectSize</code></td></tr> 124<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr> 125<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 126<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_mem_cache</td></tr> 127</table> 128 <p>The <code class="directive">MCacheMaxStreamingBuffer</code> directive 129 specifies the maximum number of bytes of a streamed response to 130 buffer before deciding that the response is too big to cache. 131 A streamed response is one in which the entire content is not 132 immediately available and in which the <code>Content-Length</code> 133 may not be known. Sources of streaming responses include proxied 134 responses and the output of CGI scripts. By default, a streamed 135 response will <em>not</em> be cached unless it has a 136 <code>Content-Length</code> header. The reason for this is to 137 avoid using a large amount of memory to buffer a partial response 138 that might end up being too large to fit in the cache. 139 The <code class="directive">MCacheMaxStreamingBuffer</code> directive allows 140 buffering of streamed responses that don't contain a 141 <code>Content-Length</code> up to the specified maximum amount of 142 space. If the maximum buffer space is reached, the buffered 143 content is discarded and the attempt to cache is abandoned.</p> 144 145 <div class="note"><h3>Note:</h3> 146 <p>Using a nonzero value for <code class="directive">MCacheMaxStreamingBuffer</code> 147 will not delay the transmission of the response to the client. 148 As soon as <code class="module"><a href="/mod/mod_mem_cache.html">mod_mem_cache</a></code> copies a block of streamed 149 content into a buffer, it sends the block on to the next output 150 filter for delivery to the client.</p> 151 </div> 152 153 <div class="example"><p><code> 154 # Enable caching of streamed responses up to 64KB:<br /> 155 MCacheMaxStreamingBuffer 65536 156 </code></p></div> 157 158</div> 159<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 160<div class="directive-section"><h2><a name="MCacheMinObjectSize" id="MCacheMinObjectSize">MCacheMinObjectSize</a> <a name="mcacheminobjectsize" id="mcacheminobjectsize">Directive</a></h2> 161<table class="directive"> 162<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The minimum size (in bytes) of a document to be allowed in the 163cache</td></tr> 164<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>MCacheMinObjectSize <var>bytes</var></code></td></tr> 165<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>MCacheMinObjectSize 1</code></td></tr> 166<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr> 167<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 168<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_mem_cache</td></tr> 169</table> 170 <p>The <code class="directive">MCacheMinObjectSize</code> directive sets the 171 minimum size in bytes of a document for it to be considered 172 cacheable.</p> 173 174 <div class="example"><h3>Example</h3><p><code> 175 MCacheMinObjectSize 10000 176 </code></p></div> 177 178</div> 179<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 180<div class="directive-section"><h2><a name="MCacheRemovalAlgorithm" id="MCacheRemovalAlgorithm">MCacheRemovalAlgorithm</a> <a name="mcacheremovalalgorithm" id="mcacheremovalalgorithm">Directive</a></h2> 181<table class="directive"> 182<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The algorithm used to select documents for removal from the 183cache</td></tr> 184<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>MCacheRemovalAlgorithm LRU|GDSF</code></td></tr> 185<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>MCacheRemovalAlgorithm GDSF</code></td></tr> 186<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr> 187<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 188<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_mem_cache</td></tr> 189</table> 190 <p>The <code class="directive">MCacheRemovalAlgorithm</code> directive specifies 191 the algorithm used to select documents for removal from the cache. 192 Two choices are available:</p> 193 194 <dl> 195 <dt><code>LRU</code> (Least Recently Used)</dt> 196 <dd><code>LRU</code> removes the documents that have not been accessed 197 for the longest time.</dd> 198 199 <dt><code>GDSF</code> (GreadyDual-Size)</dt> 200 <dd><code>GDSF</code> assigns a priority to cached documents based 201 on the cost of a cache miss and the size of the document. Documents 202 with the lowest priority are removed first.</dd> 203 </dl> 204 205 <div class="example"><h3>Example</h3><p><code> 206 MCacheRemovalAlgorithm GDSF<br /> 207 MCacheRemovalAlgorithm LRU 208 </code></p></div> 209 210</div> 211<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 212<div class="directive-section"><h2><a name="MCacheSize" id="MCacheSize">MCacheSize</a> <a name="mcachesize" id="mcachesize">Directive</a></h2> 213<table class="directive"> 214<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The maximum amount of memory used by the cache in 215KBytes</td></tr> 216<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>MCacheSize <var>KBytes</var></code></td></tr> 217<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>MCacheSize 100</code></td></tr> 218<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config</td></tr> 219<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 220<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_mem_cache</td></tr> 221</table> 222 <p>The <code class="directive">MCacheSize</code> directive sets the maximum 223 amount of memory to be used by the cache, in KBytes (1024-byte units). 224 If a new object needs to be inserted in the cache and the size of the 225 object is greater than the remaining memory, objects will be removed 226 until the new object can be cached. The object to be removed is 227 selected using the algorithm specified by <code class="directive"><a href="#mcacheremovalalgorithm">MCacheRemovalAlgorithm</a></code>.</p> 228 229 <div class="example"><h3>Example</h3><p><code> 230 MCacheSize 700000 231 </code></p></div> 232 233 <div class="note"><h3>Note</h3> 234 <p>The <code class="directive">MCacheSize</code> value must be greater than 235 the value specified by the <code class="directive"><a href="#mcachemaxobjectsize">MCacheMaxObjectSize</a></code> directive.</p> 236 </div> 237 238</div> 239</div> 240<div class="bottomlang"> 241<p><span>Available Languages: </span><a href="/en/mod/mod_mem_cache.html" title="English"> en </a> | 242<a href="/ja/mod/mod_mem_cache.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 243<a href="/ko/mod/mod_mem_cache.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p> 244</div><div class="top"><a href="#page-header"><img src="/images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div> 245<script type="text/javascript"><!--//--><![CDATA[//><!-- 246var comments_shortname = 'httpd'; 247var comments_identifier = 'http://httpd.apache.org/docs/2.2/mod/mod_mem_cache.html'; 248(function(w, d) { 249 if (w.location.hostname.toLowerCase() == "httpd.apache.org") { 250 d.write('<div id="comments_thread"><\/div>'); 251 var s = d.createElement('script'); 252 s.type = 'text/javascript'; 253 s.async = true; 254 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; 255 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); 256 } 257 else { 258 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); 259 } 260})(window, document); 261//--><!]]></script></div><div id="footer"> 262<p class="apache">Copyright 2013 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p> 263<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!-- 264if (typeof(prettyPrint) !== 'undefined') { 265 prettyPrint(); 266} 267//--><!]]></script> 268</body></html>