Content is stored in and retrieved from the cache using URI based keys. Content with access protection is not cached.
Further details, discussion, and examples, are provided in the Caching Guide.
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 unpredicably.
To keep the thundering herd at bay, the
When 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.
When 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 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 honoured 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
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 RFC2616 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 authorisation 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:
Another option is to have content cached before personalisation is applied
by
You may place the CACHE filter anywhere you wish within the
filter chain. In this example, content is cached after being parsed by
The disk instructs
In the event that the URL space overlaps between different
When acting as a forward proxy server, url-string can also be used to specify remote sites and proxy protocols which caching should be enabled for.
A hostname starting with a "*" matches all hostnames with that suffix. A hostname starting with "." matches all hostnames containing the domain components that follow.
The no-cache environment variable can be set to
disable caching on a finer grained set of resources in versions
2.2.12 and later.
The
If used in a
The no-cache environment variable can be set to
disable caching on a finer grained set of resources in versions
2.2.12 and later.
The
The
The
Ordinarily, documents without a last-modified date are not cached.
Under some circumstances the last-modified date is removed (during
Ordinarily, requests containing a Cache-Control: no-cache or
Pragma: no-cache header value will not be served from the cache. The
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
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
expiry-period = time-since-last-modified-date * factor
expiry-date = current-date + expiry-period
For example, if the document was last modified 10 hours ago, and
factor is 0.1 then the expiry-period will be set to
10*0.1 = 1 hour. If the current time was 3:00pm then the computed
expiry-date would be 3:00pm + 1hour = 4:00pm.
If the expiry-period would be longer than that set by
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
ConnectionKeep-AliveProxy-AuthenticateProxy-AuthorizationTETrailersTransfer-EncodingUpgradeNone.
Expires which are needed for proper cache
management are not stored due to a
Sometimes applications encode the session identifier into the URL like in the following Examples:
/someapplication/image.gif;jsessionid=123456789/someapplication/image.gif?PHPSESSIONID=12345678This causes cachable resources to be stored separately for each session, which
is often not desired.
CacheIgnoreURLSessionIdentifiers None clears the list of ignored
identifiers. Otherwise, each identifier is added to the list.
Ordinarily, responses with Cache-Control: private header values will not
be stored in the cache. The
Ordinarily, requests or responses with Cache-Control: no-store header
values will not be stored in the cache. The
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.
The
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.
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 authorisation.
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.
If the CACHE filter is specified more than once, the last instance will apply.