GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing httpd.apache.org — mod_cache - Apache HTTP Server Version 2.4 Apache Module mod_cache
SummaryThis module should be used with care, as when the
CacheQuickHandler directive is
in its default value of on, the Allow and Deny directives will be circumvented.
You should not enable quick handler caching for any content to which you
wish to limit access by client host name, address or environment
variable.
RFC 2616 compliant caching provides a mechanism to verify whether stale or expired content is still fresh, and can represent a significant performance boost when the origin server supports conditional requests by honoring the If-None-Match (RFC 2616) HTTP request header. Content is only regenerated from scratch when the content has changed, and not when the cached entry expires. As a filter, In the default configuration, When the quick handler is switched off using the
Under normal operation, RFC 2616 allows for the cache to return stale data while the existing
stale entry is refreshed from the origin server, and this is supported
by
Further details, discussion, and examples, are provided in the Caching Guide. Topics
Directives
Bugfix checklistSee alsoRelated Modules and Directives ¶
Sample Configuration ¶Sample httpd.conf#
# Sample Cache Configuration
#
LoadModule cache_module modules/mod_cache.so
<IfModule mod_cache.c>
LoadModule cache_disk_module modules/mod_cache_disk.so
<IfModule mod_cache_disk.c>
CacheRoot "c:/cacheroot"
CacheEnable disk "/"
CacheDirLevels 5
CacheDirLength 3
</IfModule>
# When acting as a proxy, don't cache the list of security updates
CacheDisable "http://security.update.server/update-list/"
</IfModule>
Avoiding the Thundering Herd ¶When a cached entry becomes stale, A small but finite amount of time exists between the time the cached entity becomes stale, and the time the stale entity is fully refreshed. On a busy server, a significant number of requests might arrive during this time, and cause a thundering herd of requests to strike the backend suddenly and unpredictably. To keep the thundering herd at bay, the Initial caching of an entryWhen an entity is cached for the first time, a lock will be created for the entity until the response has been fully cached. During the lifetime of the lock, the cache will suppress the second and subsequent attempt to cache the same entity. While this doesn't hold back the thundering herd, it does stop the cache attempting to cache the same entity multiple times simultaneously. Refreshment of a stale entryWhen an entity reaches its freshness lifetime and becomes stale, a lock will be created for the entity until the response has either been confirmed as still fresh, or replaced by the backend. During the lifetime of the lock, the second and subsequent incoming request will cause stale data to be returned, and the thundering herd is kept at bay. Locks and Cache-Control: no-cacheLocks are used as a hint only to enable the cache to be more gentle on backend servers, however the lock can be overridden if necessary. If the client sends a request with a Cache-Control header forcing a reload, any lock that may be present will be ignored, and the client's request will be honored immediately and the cached entry refreshed. As a further safety mechanism, locks have a configurable maximum age.
Once this age has been reached, the lock is removed, and a new request is
given the opportunity to create a new lock. This maximum age can be set using
the Example configurationEnabling the cache lock#
# Enable the cache lock
#
<IfModule mod_cache.c>
CacheLock on
CacheLockPath "/tmp/mod_cache-lock"
CacheLockMaxAge 5
</IfModule>
Fine Control with the CACHE Filter ¶Under the default mode of cache operation, the cache runs as a quick handler, short circuiting the majority of server processing and offering the highest cache performance available. In this mode, the cache bolts onto the front of the server, acting as if a free standing RFC 2616 caching proxy had been placed in front of the server. While this mode offers the best performance, the administrator may find that under certain circumstances they may want to perform further processing on the request after the request is cached, such as to inject personalisation into the cached page, or to apply authorization restrictions to the content. Under these circumstances, an administrator is often forced to place independent reverse proxy servers either behind or in front of the caching server to achieve this. To solve this problem the In addition, the administrator may optionally specify the precise point within the filter chain where caching is to take place by adding the CACHE filter to the output filter chain. For example, to cache content before applying compression to the response, place the CACHE filter before the DEFLATE filter as in the example below: # Cache content before optional compression CacheQuickHandler off AddOutputFilterByType CACHE;DEFLATE text/plain Another option is to have content cached before personalisation is applied
by # Cache content before mod_include and mod_deflate CacheQuickHandler off AddOutputFilterByType CACHE;INCLUDES;DEFLATE text/html You may place the CACHE filter anywhere you wish within the
filter chain. In this example, content is cached after being parsed by
# Cache content between mod_include and mod_deflate CacheQuickHandler off AddOutputFilterByType INCLUDES;CACHE;DEFLATE text/html Warning:If the location of the CACHE filter in the filter chain is changed for any reason, you may need to flush your cache to ensure that your data served remains consistent.mod_cache is not in a position
to enforce this for you.Cache Status and Logging ¶Once LogFormat "%{cache-status}e ..."
Based on the caching decision made, the reason is also written to the subprocess environment under one the following four keys, as appropriate:
This makes it possible to support conditional logging of cached requests as per the following example: CustomLog "cached-requests.log" common env=cache-hit CustomLog "uncached-requests.log" common env=cache-miss CustomLog "revalidated-requests.log" common env=cache-revalidate CustomLog "invalidated-requests.log" common env=cache-invalidate For module authors, a hook called cache_status is available, allowing modules to respond to the caching outcomes above in customized ways. CacheDefaultExpire Directive ¶
The CacheDefaultExpire 86400 CacheDetailHeader Directive ¶
When the It can be useful during development of cached RESTful services to have additional
information about the caching decision written to the response headers, so as to
confirm whether If the normal handler is used, this directive may appear within a
# Enable the X-Cache-Detail header CacheDetailHeader on
CacheDisable Directive ¶
This directive is only valid in
The ExampleCacheDisable "/local_files" If used in a Example<Location "/foo">
CacheDisable on
</Location>
The See alsoCacheEnable Directive ¶
The In the event that the URL space overlaps between different
When acting as a forward proxy server, url-string must minimally begin with a protocol for which caching should be enabled. # Cache content (normal handler only)
CacheQuickHandler off
<Location "/foo">
CacheEnable disk
</Location>
# Cache regex (normal handler only)
CacheQuickHandler off
<LocationMatch "foo$">
CacheEnable disk
</LocationMatch>
# Cache all but forward proxy url's (normal or quick handler)
CacheEnable disk /
# Cache FTP-proxied url's (normal or quick handler)
CacheEnable disk ftp://
# Cache forward proxy content from www.example.org (normal or quick handler)
CacheEnable disk http://www.example.org/
A hostname starting with a "*" matches all hostnames with that suffix. A hostname starting with "." matches all hostnames containing the domain components that follow. # Match www.example.org, and fooexample.org CacheEnable disk "http://*example.org/" # Match www.example.org, but not fooexample.org CacheEnable disk "http://.example.org/" The See alsoCacheHeader Directive ¶
When the
# Enable the X-Cache header CacheHeader on X-Cache: HIT from localhost CacheIgnoreCacheControl Directive ¶
Ordinarily, requests containing a CacheIgnoreCacheControl On Warning:This directive will allow serving from the cache even if the client has requested that the document not be served from the cache. This might result in stale content being served.See alsoCacheIgnoreHeaders Directive ¶
According to RFC 2616, hop-by-hop HTTP headers are not stored in
the cache. The following HTTP headers are hop-by-hop headers and thus
do not get stored in the cache in any case regardless of the
setting of
Example 1CacheIgnoreHeaders Set-Cookie Example 2CacheIgnoreHeaders None Warning:If headers likeExpires which are needed for proper cache
management are not stored due to a
CacheIgnoreHeaders setting, the behavior of
mod_cache is undefined.
CacheIgnoreNoLastMod Directive ¶
Ordinarily, documents without a last-modified date are not cached.
Under some circumstances the last-modified date is removed (during
More precisely, a 200 OK response is only cached if it includes
at least one of the
Last-Modified, ETag,
or Expires headers, or a Cache-Control: max-age
or s-maxage directive. This directive bypasses that
requirement entirely. When any of those headers are already present,
this directive has no effect.CacheIgnoreNoLastMod On CacheIgnoreQueryString Directive ¶
Ordinarily, requests with query string parameters are cached separately
for each unique query string. This is according to RFC 2616/13.9 done only
if an expiration time is specified. The
CacheIgnoreQueryString On CacheIgnoreURLSessionIdentifiers Directive ¶
Sometimes applications encode the session identifier into the URL like in the following Examples:
This causes cacheable resources to be stored separately for each session, which
is often not desired.
Example 1CacheIgnoreURLSessionIdentifiers jsessionid Example 2CacheIgnoreURLSessionIdentifiers None CacheKeyBaseURL Directive ¶
When the # Override the base URL of the cache key. CacheKeyBaseURL "http://www.example.com/" Take care when setting this directive. If two separate virtual
hosts are accidentally given the same base URL, entries from one virtual host
will be served to the other.
CacheLastModifiedFactor Directive ¶
In the event that a document does not provide an expiry date but does
provide a last-modified date, an expiry date can be calculated based on
the time since the document was last modified. The
CacheLastModifiedFactor 0.5 CacheLock Directive ¶
The In a minimal configuration the following directive is all that is needed to enable the thundering herd lock in the default system temp directory. # Enable cache lock CacheLock on CacheLockMaxAge Directive ¶
The A lock older than this value in seconds will be ignored, and the next incoming request will be given the opportunity to re-establish the lock. This mechanism prevents a slow client taking an excessively long time to refresh an entity. CacheLockPath Directive ¶
The CacheMaxExpire Directive ¶
The CacheMaxExpire 604800 CacheMinExpire Directive ¶
The CacheMinExpire 3600 CacheQuickHandler Directive ¶
The In the default enabled configuration, the cache operates within the quick handler phase. This phase short circuits the majority of server processing, and represents the most performant mode of operation for a typical server. The cache bolts onto the front of the server, and the majority of server processing is avoided. When disabled, the cache operates as a normal handler, and is subject to the full set of phases when handling a server request. While this mode is slower than the default, it allows the cache to be used in cases where full processing is required, such as when content is subject to authorization. # Run cache as a normal handler CacheQuickHandler off It is also possible, when the quick handler is disabled, for the administrator to choose the precise location within the filter chain where caching is to be performed, by adding the CACHE filter to the chain. # Cache content before mod_include and mod_deflate CacheQuickHandler off AddOutputFilterByType CACHE;INCLUDES;DEFLATE text/html If the CACHE filter is specified more than once, the last instance will apply. CacheStaleOnError Directive ¶
When the # Serve stale data on error. CacheStaleOnError on CacheStoreExpired Directive ¶
Since httpd 2.2.4, responses which have already expired are not
stored in the cache. The CacheStoreExpired On CacheStoreNoStore Directive ¶
Ordinarily, requests or responses with CacheStoreNoStore On Warning:As described in RFC 2616, the no-store directive is intended to "prevent the inadvertent release or retention of sensitive information (for example, on backup tapes)." Enabling this option could store sensitive information in the cache. You are hereby warned.See alsoCacheStorePrivate Directive ¶
Ordinarily, responses with CacheStorePrivate On Warning:This directive will allow caching even if the upstream server has requested that the resource not be cached. This directive is only ideal for a 'private' cache.See also | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |