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_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_cache</h1> 26<div class="toplang"> 27<p><span>Available Languages: </span><a href="/en/mod/mod_cache.html" title="English"> en </a> | 28<a href="/ja/mod/mod_cache.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 29<a href="/ko/mod/mod_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>cache_module</td></tr> 34<tr><th><a href="module-dict.html#SourceFile">Source�File:</a></th><td>mod_cache.c</td></tr></table> 35<h3>Summary</h3> 36 37 <div class="warning">This module should be used with care and 38 can be used to circumvent <code class="directive"><a href="/mod/mod_authz_host.html#allow">Allow</a></code> and <code class="directive"><a href="/mod/mod_authz_host.html#deny">Deny</a></code> directives. You 39 should not enable caching for any content to which you wish 40 to limit access by client host name, address or environment 41 variable.</div> 42 43 <p><code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> implements an <a href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a> compliant HTTP 44 content cache that can be used to cache either local or proxied content. 45 <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> requires the services of one or more storage 46 management modules. Two storage management modules are included in 47 the base Apache distribution:</p> 48 <dl> 49 <dt><code class="module"><a href="/mod/mod_disk_cache.html">mod_disk_cache</a></code></dt> 50 <dd>implements a disk based storage manager.</dd> 51 52 <dt><code class="module"><a href="/mod/mod_mem_cache.html">mod_mem_cache</a></code></dt> 53 <dd>implements a memory based storage manager. 54 <code class="module"><a href="/mod/mod_mem_cache.html">mod_mem_cache</a></code> can be configured to operate in two 55 modes: caching open file descriptors or caching objects in heap storage. 56 <code class="module"><a href="/mod/mod_mem_cache.html">mod_mem_cache</a></code> can be used to cache locally generated content 57 or to cache backend server content for <code class="module"><a href="/mod/mod_proxy.html">mod_proxy</a></code> when 58 configured using <code class="directive"><a href="/mod/mod_proxy.html#proxypass">ProxyPass</a></code> 59 (aka <dfn>reverse proxy</dfn>)</dd> 60 </dl> 61 62 <p>Content is stored in and retrieved from the cache using URI based keys. Content with 63 access protection is not cached.</p> 64 <p>Further details, discussion, and examples, are provided in the 65 <a href="/caching.html">Caching Guide</a>.</p> 66</div> 67<div id="quickview"><h3 class="directives">Directives</h3> 68<ul id="toc"> 69<li><img alt="" src="/images/down.gif" /> <a href="#cachedefaultexpire">CacheDefaultExpire</a></li> 70<li><img alt="" src="/images/down.gif" /> <a href="#cachedisable">CacheDisable</a></li> 71<li><img alt="" src="/images/down.gif" /> <a href="#cacheenable">CacheEnable</a></li> 72<li><img alt="" src="/images/down.gif" /> <a href="#cacheignorecachecontrol">CacheIgnoreCacheControl</a></li> 73<li><img alt="" src="/images/down.gif" /> <a href="#cacheignoreheaders">CacheIgnoreHeaders</a></li> 74<li><img alt="" src="/images/down.gif" /> <a href="#cacheignorenolastmod">CacheIgnoreNoLastMod</a></li> 75<li><img alt="" src="/images/down.gif" /> <a href="#cacheignorequerystring">CacheIgnoreQueryString</a></li> 76<li><img alt="" src="/images/down.gif" /> <a href="#cacheignoreurlsessionidentifiers">CacheIgnoreURLSessionIdentifiers</a></li> 77<li><img alt="" src="/images/down.gif" /> <a href="#cachelastmodifiedfactor">CacheLastModifiedFactor</a></li> 78<li><img alt="" src="/images/down.gif" /> <a href="#cachelock">CacheLock</a></li> 79<li><img alt="" src="/images/down.gif" /> <a href="#cachelockmaxage">CacheLockMaxAge</a></li> 80<li><img alt="" src="/images/down.gif" /> <a href="#cachelockpath">CacheLockPath</a></li> 81<li><img alt="" src="/images/down.gif" /> <a href="#cachemaxexpire">CacheMaxExpire</a></li> 82<li><img alt="" src="/images/down.gif" /> <a href="#cachestorenostore">CacheStoreNoStore</a></li> 83<li><img alt="" src="/images/down.gif" /> <a href="#cachestoreprivate">CacheStorePrivate</a></li> 84</ul> 85<h3>Topics</h3> 86<ul id="topics"> 87<li><img alt="" src="/images/down.gif" /> <a href="#related">Related Modules and Directives</a></li> 88<li><img alt="" src="/images/down.gif" /> <a href="#sampleconf">Sample Configuration</a></li> 89<li><img alt="" src="/images/down.gif" /> <a href="#thunderingherd">Avoiding the Thundering Herd</a></li> 90</ul><h3>See also</h3> 91<ul class="seealso"> 92<li><a href="/caching.html">Caching Guide</a></li> 93</ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div> 94<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 95<div class="section"> 96<h2><a name="related" id="related">Related Modules and Directives</a></h2> 97 <table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="/mod/mod_disk_cache.html">mod_disk_cache</a></code></li><li><code class="module"><a href="/mod/mod_mem_cache.html">mod_mem_cache</a></code></li></ul></td><td><ul><li><code class="directive"><a href="/mod/mod_disk_cache.html#cacheroot">CacheRoot</a></code></li><li><code class="directive"><a href="/mod/mod_disk_cache.html#cachedirlevels">CacheDirLevels</a></code></li><li><code class="directive"><a href="/mod/mod_disk_cache.html#cachedirlength">CacheDirLength</a></code></li><li><code class="directive"><a href="/mod/mod_disk_cache.html#cacheminfilesize">CacheMinFileSize</a></code></li><li><code class="directive"><a href="/mod/mod_disk_cache.html#cachemaxfilesize">CacheMaxFileSize</a></code></li><li><code class="directive"><a href="/mod/mod_mem_cache.html#mcachesize">MCacheSize</a></code></li><li><code class="directive"><a href="/mod/mod_mem_cache.html#mcachemaxobjectcount">MCacheMaxObjectCount</a></code></li><li><code class="directive"><a href="/mod/mod_mem_cache.html#mcacheminobjectsize">MCacheMinObjectSize</a></code></li><li><code class="directive"><a href="/mod/mod_mem_cache.html#mcachemaxobjectsize">MCacheMaxObjectSize</a></code></li><li><code class="directive"><a href="/mod/mod_mem_cache.html#mcacheremovalalgorithm">MCacheRemovalAlgorithm</a></code></li><li><code class="directive"><a href="/mod/mod_mem_cache.html#mcachemaxstreamingbuffer">MCacheMaxStreamingBuffer</a></code></li></ul></td></tr></table> 98</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 99<div class="section"> 100<h2><a name="sampleconf" id="sampleconf">Sample Configuration</a></h2> 101 <div class="example"><h3>Sample httpd.conf</h3><p><code> 102 #<br /> 103 # Sample Cache Configuration<br /> 104 #<br /> 105 LoadModule cache_module modules/mod_cache.so<br /> 106 <br /> 107 <IfModule mod_cache.c><br /> 108 <span class="indent"> 109 #LoadModule disk_cache_module modules/mod_disk_cache.so<br /> 110 # If you want to use mod_disk_cache instead of mod_mem_cache,<br /> 111 # uncomment the line above and comment out the LoadModule line below.<br /> 112 <IfModule mod_disk_cache.c><br /> 113 <span class="indent"> 114 CacheRoot c:/cacheroot<br /> 115 CacheEnable disk /<br /> 116 CacheDirLevels 5<br /> 117 CacheDirLength 3<br /> 118 </span> 119 </IfModule> <br /> 120 <br /> 121 LoadModule mem_cache_module modules/mod_mem_cache.so<br /> 122 <IfModule mod_mem_cache.c><br /> 123 <span class="indent"> 124 CacheEnable mem /<br /> 125 MCacheSize 4096<br /> 126 MCacheMaxObjectCount 100<br /> 127 MCacheMinObjectSize 1<br /> 128 MCacheMaxObjectSize 2048<br /> 129 </span> 130 </IfModule><br /> 131 <br /> 132 # When acting as a proxy, don't cache the list of security updates<br /> 133 CacheDisable http://security.update.server/update-list/<br /> 134 </span> 135 </IfModule> 136 </code></p></div> 137</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 138<div class="section"> 139<h2><a name="thunderingherd" id="thunderingherd">Avoiding the Thundering Herd</a></h2> 140 <p>When a cached entry becomes stale, <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> will submit 141 a conditional request to the backend, which is expected to confirm whether the 142 cached entry is still fresh, and send an updated entity if not.</p> 143 <p>A small but finite amount of time exists between the time the cached entity 144 becomes stale, and the time the stale entity is fully refreshed. On a busy 145 server, a significant number of requests might arrive during this time, and 146 cause a <strong>thundering herd</strong> of requests to strike the backend 147 suddenly and unpredictably.</p> 148 <p>To keep the thundering herd at bay, the <code class="directive">CacheLock</code> 149 directive can be used to define a directory in which locks are created for 150 URLs <strong>in flight</strong>. The lock is used as a <strong>hint</strong> 151 by other requests to either suppress an attempt to cache (someone else has 152 gone to fetch the entity), or to indicate that a stale entry is being refreshed 153 (stale content will be returned in the mean time). 154 </p> 155 <h3>Initial caching of an entry</h3> 156 157 <p>When an entity is cached for the first time, a lock will be created for the 158 entity until the response has been fully cached. During the lifetime of the 159 lock, the cache will suppress the second and subsequent attempt to cache the 160 same entity. While this doesn't hold back the thundering herd, it does stop 161 the cache attempting to cache the same entity multiple times simultaneously. 162 </p> 163 164 <h3>Refreshment of a stale entry</h3> 165 166 <p>When an entity reaches its freshness lifetime and becomes stale, a lock 167 will be created for the entity until the response has either been confirmed as 168 still fresh, or replaced by the backend. During the lifetime of the lock, the 169 second and subsequent incoming request will cause stale data to be returned, 170 and the thundering herd is kept at bay.</p> 171 172 <h3>Locks and Cache-Control: no-cache</h3> 173 174 <p>Locks are used as a <strong>hint only</strong> to enable the cache to be 175 more gentle on backend servers, however the lock can be overridden if necessary. 176 If the client sends a request with a Cache-Control header forcing a reload, any 177 lock that may be present will be ignored, and the client's request will be 178 honoured immediately and the cached entry refreshed.</p> 179 <p>As a further safety mechanism, locks have a configurable maximum age. 180 Once this age has been reached, the lock is removed, and a new request is 181 given the opportunity to create a new lock. This maximum age can be set using 182 the <code class="directive">CacheLockMaxAge</code> directive, and defaults to 5 183 seconds. 184 </p> 185 186 <h3>Example configuration</h3> 187 188 <div class="example"><h3>Enabling the cache lock</h3><p><code> 189 #<br /> 190 # Enable the cache lock<br /> 191 #<br /> 192 <IfModule mod_cache.c><br /> 193 <span class="indent"> 194 CacheLock on<br /> 195 CacheLockPath /tmp/mod_cache-lock<br /> 196 CacheLockMaxAge 5<br /> 197 </span> 198 </IfModule> 199 </code></p></div> 200 201</div> 202<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 203<div class="directive-section"><h2><a name="CacheDefaultExpire" id="CacheDefaultExpire">CacheDefaultExpire</a> <a name="cachedefaultexpire" id="cachedefaultexpire">Directive</a></h2> 204<table class="directive"> 205<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The default duration to cache a document when no expiry date is specified.</td></tr> 206<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheDefaultExpire <var>seconds</var></code></td></tr> 207<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheDefaultExpire 3600 (one hour)</code></td></tr> 208<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 209<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 210<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 211</table> 212 <p>The <code class="directive">CacheDefaultExpire</code> 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 <code class="directive">CacheMaxExpire</code> 215 directive does <em>not</em> override this setting.</p> 216 217 <div class="example"><p><code> 218 CacheDefaultExpire 86400 219 </code></p></div> 220 221</div> 222<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 223<div class="directive-section"><h2><a name="CacheDisable" id="CacheDisable">CacheDisable</a> <a name="cachedisable" id="cachedisable">Directive</a></h2> 224<table class="directive"> 225<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Disable caching of specified URLs</td></tr> 226<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheDisable <var> url-string</var></code></td></tr> 227<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 228<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 229<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 230</table> 231 <p>The <code class="directive">CacheDisable</code> directive instructs 232 <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> to <em>not</em> cache urls at or below 233 <var>url-string</var>.</p> 234 235 <div class="example"><h3>Example</h3><p><code> 236 CacheDisable /local_files 237 </code></p></div> 238 239 <p> The <code>no-cache</code> environment variable can be set to 240 disable caching on a finer grained set of resources in versions 241 2.2.12 and later.</p> 242 243 244<h3>See also</h3> 245<ul> 246<li><a href="/env.html">Environment Variables in Apache</a></li> 247</ul> 248</div> 249<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 250<div class="directive-section"><h2><a name="CacheEnable" id="CacheEnable">CacheEnable</a> <a name="cacheenable" id="cacheenable">Directive</a></h2> 251<table class="directive"> 252<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enable caching of specified URLs using a specified storage 253manager</td></tr> 254<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheEnable <var>cache_type</var> <var>url-string</var></code></td></tr> 255<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 256<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 257<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 258</table> 259 <p>The <code class="directive">CacheEnable</code> directive instructs 260 <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> to cache urls at or below 261 <var>url-string</var>. The cache storage manager is specified with the 262 <var>cache_type</var> argument. <var>cache_type</var> <code> mem</code> 263 instructs <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> to use the memory based storage 264 manager implemented by <code class="module"><a href="/mod/mod_mem_cache.html">mod_mem_cache</a></code>. 265 <var>cache_type</var> <code>disk</code> instructs 266 <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> to use the disk based storage manager 267 implemented by <code class="module"><a href="/mod/mod_disk_cache.html">mod_disk_cache</a></code>. 268 <var>cache_type</var> <code>fd</code> instructs 269 <code class="module"><a href="/mod/mod_cache.html">mod_cache</a></code> to use the file descriptor cache implemented 270 by <code class="module"><a href="/mod/mod_mem_cache.html">mod_mem_cache</a></code>.</p> 271 <p>In the event that the URL space overlaps between different 272 <code class="directive">CacheEnable</code> directives (as in the example below), 273 each possible storage manager will be run until the first one that 274 actually processes the request. The order in which the storage managers are 275 run is determined by the order of the <code class="directive">CacheEnable</code> 276 directives in the configuration file.</p> 277 278 <div class="example"><p><code> 279 CacheEnable mem /manual<br /> 280 CacheEnable fd /images<br /> 281 CacheEnable disk /<br /> 282 </code></p></div> 283 284 <p>When acting as a forward proxy server, <var>url-string</var> can 285 also be used to specify remote sites and proxy protocols which 286 caching should be enabled for.</p> 287 288 <div class="example"><p><code> 289 # Cache proxied url's<br /> 290 CacheEnable disk /<br /><br /> 291 # Cache FTP-proxied url's<br /> 292 CacheEnable disk ftp://<br /><br /> 293 # Cache content from www.apache.org<br /> 294 CacheEnable disk http://www.apache.org/<br /> 295 </code></p></div> 296 297 <p> The <code>no-cache</code> environment variable can be set to 298 disable caching on a finer grained set of resources in versions 299 2.2.12 and later.</p> 300 301 302<h3>See also</h3> 303<ul> 304<li><a href="/env.html">Environment Variables in Apache</a></li> 305</ul> 306</div> 307<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 308<div class="directive-section"><h2><a name="CacheIgnoreCacheControl" id="CacheIgnoreCacheControl">CacheIgnoreCacheControl</a> <a name="cacheignorecachecontrol" id="cacheignorecachecontrol">Directive</a></h2> 309<table class="directive"> 310<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Ignore request to not serve cached content to client</td></tr> 311<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheIgnoreCacheControl On|Off</code></td></tr> 312<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheIgnoreCacheControl Off</code></td></tr> 313<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 314<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 315<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 316</table> 317 <p>Ordinarily, requests containing a Cache-Control: no-cache or 318 Pragma: no-cache header value will not be served from the cache. The 319 <code class="directive">CacheIgnoreCacheControl</code> directive allows this 320 behavior to be overridden. <code class="directive">CacheIgnoreCacheControl</code> 321 On tells the server to attempt to serve the resource from the cache even 322 if the request contains no-cache header values. Resources requiring 323 authorization will <em>never</em> be cached.</p> 324 325 <div class="example"><p><code> 326 CacheIgnoreCacheControl On 327 </code></p></div> 328 329 <div class="warning"><h3>Warning:</h3> 330 This directive will allow serving from the cache even if the client has 331 requested that the document not be served from the cache. This might 332 result in stale content being served. 333 </div> 334 335<h3>See also</h3> 336<ul> 337<li><code class="directive"><a href="#cachestoreprivate">CacheStorePrivate</a></code></li> 338<li><code class="directive"><a href="#cachestorenostore">CacheStoreNoStore</a></code></li> 339</ul> 340</div> 341<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 342<div class="directive-section"><h2><a name="CacheIgnoreHeaders" id="CacheIgnoreHeaders">CacheIgnoreHeaders</a> <a name="cacheignoreheaders" id="cacheignoreheaders">Directive</a></h2> 343<table class="directive"> 344<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Do not store the given HTTP header(s) in the cache. 345</td></tr> 346<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheIgnoreHeaders <var>header-string</var> [<var>header-string</var>] ...</code></td></tr> 347<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheIgnoreHeaders None</code></td></tr> 348<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 349<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 350<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 351</table> 352 <p>According to RFC 2616, hop-by-hop HTTP headers are not stored in 353 the cache. The following HTTP headers are hop-by-hop headers and thus 354 do not get stored in the cache in <em>any</em> case regardless of the 355 setting of <code class="directive">CacheIgnoreHeaders</code>:</p> 356 357 <ul> 358 <li><code>Connection</code></li> 359 <li><code>Keep-Alive</code></li> 360 <li><code>Proxy-Authenticate</code></li> 361 <li><code>Proxy-Authorization</code></li> 362 <li><code>TE</code></li> 363 <li><code>Trailers</code></li> 364 <li><code>Transfer-Encoding</code></li> 365 <li><code>Upgrade</code></li> 366 </ul> 367 368 <p><code class="directive">CacheIgnoreHeaders</code> specifies additional HTTP 369 headers that should not to be stored in the cache. For example, it makes 370 sense in some cases to prevent cookies from being stored in the cache.</p> 371 372 <p><code class="directive">CacheIgnoreHeaders</code> takes a space separated list 373 of HTTP headers that should not be stored in the cache. If only hop-by-hop 374 headers not should be stored in the cache (the RFC 2616 compliant 375 behaviour), <code class="directive">CacheIgnoreHeaders</code> can be set to 376 <code>None</code>.</p> 377 378 <div class="example"><h3>Example 1</h3><p><code> 379 CacheIgnoreHeaders Set-Cookie 380 </code></p></div> 381 382 <div class="example"><h3>Example 2</h3><p><code> 383 CacheIgnoreHeaders None 384 </code></p></div> 385 386 <div class="warning"><h3>Warning:</h3> 387 If headers like <code>Expires</code> which are needed for proper cache 388 management are not stored due to a 389 <code class="directive">CacheIgnoreHeaders</code> setting, the behaviour of 390 mod_cache is undefined. 391 </div> 392 393</div> 394<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 395<div class="directive-section"><h2><a name="CacheIgnoreNoLastMod" id="CacheIgnoreNoLastMod">CacheIgnoreNoLastMod</a> <a name="cacheignorenolastmod" id="cacheignorenolastmod">Directive</a></h2> 396<table class="directive"> 397<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Ignore the fact that a response has no Last Modified 398header.</td></tr> 399<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheIgnoreNoLastMod On|Off</code></td></tr> 400<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheIgnoreNoLastMod Off</code></td></tr> 401<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 402<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 403<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 404</table> 405 <p>Ordinarily, documents without a last-modified date are not cached. 406 Under some circumstances the last-modified date is removed (during 407 <code class="module"><a href="/mod/mod_include.html">mod_include</a></code> processing for example) or not provided 408 at all. The <code class="directive">CacheIgnoreNoLastMod</code> directive 409 provides a way to specify that documents without last-modified dates 410 should be considered for caching, even without a last-modified date. 411 If neither a last-modified date nor an expiry date are provided with 412 the document then the value specified by the 413 <code class="directive">CacheDefaultExpire</code> directive will be used to 414 generate an expiration date.</p> 415 416 <div class="example"><p><code> 417 CacheIgnoreNoLastMod On 418 </code></p></div> 419 420</div> 421<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 422<div class="directive-section"><h2><a name="CacheIgnoreQueryString" id="CacheIgnoreQueryString">CacheIgnoreQueryString</a> <a name="cacheignorequerystring" id="cacheignorequerystring">Directive</a></h2> 423<table class="directive"> 424<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Ignore query string when caching</td></tr> 425<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheIgnoreQueryString On|Off</code></td></tr> 426<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheIgnoreQueryString Off</code></td></tr> 427<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 428<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 429<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 430<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.2.6 and later</td></tr> 431</table> 432 <p>Ordinarily, requests with query string parameters are cached separately 433 for each unique query string. This is according to RFC 2616/13.9 done only 434 if an expiration time is specified. The 435 <code class="directive">CacheIgnoreQueryString</code> directive tells the cache to 436 cache requests even if no expiration time is specified, and to reply with 437 a cached reply even if the query string differs. From a caching point of 438 view the request is treated as if having no query string when this 439 directive is enabled.</p> 440 441 <div class="example"><p><code> 442 CacheIgnoreQueryString On 443 </code></p></div> 444 445 446</div> 447<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 448<div class="directive-section"><h2><a name="CacheIgnoreURLSessionIdentifiers" id="CacheIgnoreURLSessionIdentifiers">CacheIgnoreURLSessionIdentifiers</a> <a name="cacheignoreurlsessionidentifiers" id="cacheignoreurlsessionidentifiers">Directive</a></h2> 449<table class="directive"> 450<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Ignore defined session identifiers encoded in the URL when caching 451</td></tr> 452<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheIgnoreURLSessionIdentifiers <var>identifier</var> [<var>identifier</var>] ...</code></td></tr> 453<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheIgnoreURLSessionIdentifiers None</code></td></tr> 454<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 455<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 456<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 457</table> 458 <p>Sometimes applications encode the session identifier into the URL like in the following 459 Examples: 460 </p> 461 <ul> 462 <li><code>/someapplication/image.gif;jsessionid=123456789</code></li> 463 <li><code>/someapplication/image.gif?PHPSESSIONID=12345678</code></li> 464 </ul> 465 <p>This causes cachable resources to be stored separately for each session, which 466 is often not desired. <code class="directive">CacheIgnoreURLSessionIdentifiers</code> lets 467 define a list of identifiers that are removed from the key that is used to identify 468 an entity in the cache, such that cachable resources are not stored separately for 469 each session. 470 </p> 471 <p><code>CacheIgnoreURLSessionIdentifiers None</code> clears the list of ignored 472 identifiers. Otherwise, each identifier is added to the list.</p> 473 474 <div class="example"><h3>Example 1</h3><p><code> 475 CacheIgnoreURLSessionIdentifiers jsessionid 476 </code></p></div> 477 478 <div class="example"><h3>Example 2</h3><p><code> 479 CacheIgnoreURLSessionIdentifiers None 480 </code></p></div> 481 482 483</div> 484<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 485<div class="directive-section"><h2><a name="CacheLastModifiedFactor" id="CacheLastModifiedFactor">CacheLastModifiedFactor</a> <a name="cachelastmodifiedfactor" id="cachelastmodifiedfactor">Directive</a></h2> 486<table class="directive"> 487<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The factor used to compute an expiry date based on the 488LastModified date.</td></tr> 489<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheLastModifiedFactor <var>float</var></code></td></tr> 490<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheLastModifiedFactor 0.1</code></td></tr> 491<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 492<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 493<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 494</table> 495 <p>In the event that a document does not provide an expiry date but does 496 provide a last-modified date, an expiry date can be calculated based on 497 the time since the document was last modified. The 498 <code class="directive">CacheLastModifiedFactor</code> directive specifies a 499 <var>factor</var> to be used in the generation of this expiry date 500 according to the following formula: 501 502 <code>expiry-period = time-since-last-modified-date * <var>factor</var> 503 expiry-date = current-date + expiry-period</code> 504 505 For example, if the document was last modified 10 hours ago, and 506 <var>factor</var> is 0.1 then the expiry-period will be set to 507 10*0.1 = 1 hour. If the current time was 3:00pm then the computed 508 expiry-date would be 3:00pm + 1hour = 4:00pm. 509 510 If the expiry-period would be longer than that set by 511 <code class="directive">CacheMaxExpire</code>, then the latter takes 512 precedence.</p> 513 514 <div class="example"><p><code> 515 CacheLastModifiedFactor 0.5 516 </code></p></div> 517 518</div> 519<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 520<div class="directive-section"><h2><a name="CacheLock" id="CacheLock">CacheLock</a> <a name="cachelock" id="cachelock">Directive</a></h2> 521<table class="directive"> 522<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Enable the thundering herd lock.</td></tr> 523<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheLock <var>on|off</var></code></td></tr> 524<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheLock off</code></td></tr> 525<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 526<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 527<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 528<tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.2.15 and later</td></tr> 529</table> 530 <p>The <code class="directive">CacheLock</code> directive enables the thundering herd lock 531 for the given URL space.</p> 532 533 <p>In a minimal configuration the following directive is all that is needed to 534 enable the thundering herd lock in the default system temp directory.</p> 535 536 <div class="example"><p><code> 537 # Enable chache lock<br /> 538 CacheLock on<br /><br /> 539 </code></p></div> 540 541 542</div> 543<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 544<div class="directive-section"><h2><a name="CacheLockMaxAge" id="CacheLockMaxAge">CacheLockMaxAge</a> <a name="cachelockmaxage" id="cachelockmaxage">Directive</a></h2> 545<table class="directive"> 546<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Set the maximum possible age of a cache lock.</td></tr> 547<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheLockMaxAge <var>integer</var></code></td></tr> 548<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheLockMaxAge 5</code></td></tr> 549<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 550<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 551<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 552</table> 553 <p>The <code class="directive">CacheLockMaxAge</code> directive specifies the maximum 554 age of any cache lock.</p> 555 556 <p>A lock older than this value in seconds will be ignored, and the next 557 incoming request will be given the opportunity to re-establish the lock. 558 This mechanism prevents a slow client taking an excessively long time to refresh 559 an entity.</p> 560 561 562</div> 563<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 564<div class="directive-section"><h2><a name="CacheLockPath" id="CacheLockPath">CacheLockPath</a> <a name="cachelockpath" id="cachelockpath">Directive</a></h2> 565<table class="directive"> 566<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Set the lock path directory.</td></tr> 567<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheLockPath <var>directory</var></code></td></tr> 568<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheLockPath /tmp/mod_cache-lock</code></td></tr> 569<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 570<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 571<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 572</table> 573 <p>The <code class="directive">CacheLockPath</code> directive allows you to specify the 574 directory in which the locks are created. By default, the system's temporary 575 folder is used. Locks consist of empty files that only exist for stale URLs 576 in flight, so is significantly less resource intensive than the traditional 577 disk cache.</p> 578 579 580</div> 581<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 582<div class="directive-section"><h2><a name="CacheMaxExpire" id="CacheMaxExpire">CacheMaxExpire</a> <a name="cachemaxexpire" id="cachemaxexpire">Directive</a></h2> 583<table class="directive"> 584<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>The maximum time in seconds to cache a document</td></tr> 585<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheMaxExpire <var>seconds</var></code></td></tr> 586<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheMaxExpire 86400 (one day)</code></td></tr> 587<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 588<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 589<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 590</table> 591 <p>The <code class="directive">CacheMaxExpire</code> directive specifies the maximum number of 592 seconds for which cachable HTTP documents will be retained without checking the origin 593 server. Thus, documents will be out of date at most this number of seconds. This maximum 594 value is enforced even if an expiry date was supplied with the document.</p> 595 596 <div class="example"><p><code> 597 CacheMaxExpire 604800 598 </code></p></div> 599 600</div> 601<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 602<div class="directive-section"><h2><a name="CacheStoreNoStore" id="CacheStoreNoStore">CacheStoreNoStore</a> <a name="cachestorenostore" id="cachestorenostore">Directive</a></h2> 603<table class="directive"> 604<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Attempt to cache requests or responses that have been marked as no-store.</td></tr> 605<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheStoreNoStore On|Off</code></td></tr> 606<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheStoreNoStore Off</code></td></tr> 607<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 608<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 609<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 610</table> 611 <p>Ordinarily, requests or responses with Cache-Control: no-store header 612 values will not be stored in the cache. The 613 <code class="directive">CacheStoreNoStore</code> directive allows this 614 behavior to be overridden. <code class="directive">CacheStoreNoStore</code> On 615 tells the server to attempt to cache the resource even if it contains 616 no-store header values. Resources requiring authorization will 617 <em>never</em> be cached.</p> 618 619 <div class="example"><p><code> 620 CacheStoreNoStore On 621 </code></p></div> 622 623 <div class="warning"><h3>Warning:</h3> 624 As described in RFC 2616, the no-store directive is intended to 625 "prevent the inadvertent release or retention of sensitive information 626 (for example, on backup tapes)." Enabling this option could store 627 sensitive information in the cache. You are hereby warned. 628 </div> 629 630<h3>See also</h3> 631<ul> 632<li><code class="directive"><a href="#cacheignorecachecontrol">CacheIgnoreCacheControl</a></code></li> 633<li><code class="directive"><a href="#cachestoreprivate">CacheStorePrivate</a></code></li> 634</ul> 635</div> 636<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 637<div class="directive-section"><h2><a name="CacheStorePrivate" id="CacheStorePrivate">CacheStorePrivate</a> <a name="cachestoreprivate" id="cachestoreprivate">Directive</a></h2> 638<table class="directive"> 639<tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Attempt to cache responses that the server has marked as private</td></tr> 640<tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>CacheStorePrivate On|Off</code></td></tr> 641<tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>CacheStorePrivate Off</code></td></tr> 642<tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr> 643<tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr> 644<tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_cache</td></tr> 645</table> 646 <p>Ordinarily, responses with Cache-Control: private header values will not 647 be stored in the cache. The <code class="directive">CacheStorePrivate</code> 648 directive allows this behavior to be overridden. 649 <code class="directive">CacheStorePrivate</code> On 650 tells the server to attempt to cache the resource even if it contains 651 private header values. Resources requiring authorization will 652 <em>never</em> be cached.</p> 653 654 <div class="example"><p><code> 655 CacheStorePrivate On 656 </code></p></div> 657 658 <div class="warning"><h3>Warning:</h3> 659 This directive will allow caching even if the upstream server has 660 requested that the resource not be cached. This directive is only 661 ideal for a 'private' cache. 662 </div> 663 664<h3>See also</h3> 665<ul> 666<li><code class="directive"><a href="#cacheignorecachecontrol">CacheIgnoreCacheControl</a></code></li> 667<li><code class="directive"><a href="#cachestorenostore">CacheStoreNoStore</a></code></li> 668</ul> 669</div> 670</div> 671<div class="bottomlang"> 672<p><span>Available Languages: </span><a href="/en/mod/mod_cache.html" title="English"> en </a> | 673<a href="/ja/mod/mod_cache.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> | 674<a href="/ko/mod/mod_cache.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p> 675</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> 676<script type="text/javascript"><!--//--><![CDATA[//><!-- 677var comments_shortname = 'httpd'; 678var comments_identifier = 'http://httpd.apache.org/docs/2.2/mod/mod_cache.html'; 679(function(w, d) { 680 if (w.location.hostname.toLowerCase() == "httpd.apache.org") { 681 d.write('<div id="comments_thread"><\/div>'); 682 var s = d.createElement('script'); 683 s.type = 'text/javascript'; 684 s.async = true; 685 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; 686 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); 687 } 688 else { 689 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); 690 } 691})(window, document); 692//--><!]]></script></div><div id="footer"> 693<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> 694<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[//><!-- 695if (typeof(prettyPrint) !== 'undefined') { 696 prettyPrint(); 697} 698//--><!]]></script> 699</body></html>