From: Colm MacCarthaigh When caching locally generated content, ensuring that
If you are using Server Side Includes, and want the benefit of speedy
serves from the cache, you should use The default expiry period for cached entities is one hour, however
this can be easily over-ridden by using the The maximum expiry period may also be controlled by using the
When content expires from the cache and is re-requested from the
backend or content provider, rather than pass on the original request,
Aoache will use a conditional request instead.Improving Cache Hits
-
-
UseCanonicalName is set to
On can dramatically improve the ratio of cache hits. This
@@ -139,13 +137,11 @@
virtual include
types.Expiry Periods
-
CacheDefaultExpire directive. This
default is only used when the original source of the content does not
@@ -160,14 +156,12 @@
CacheMaxExpire.A Brief Guide to Conditional Requests
-
As mentioned already, the two styles of caching in Apache work
differently, mod_file_cache caching maintains file
contents as they were when Apache was started. When a request is
@@ -260,15 +252,11 @@
In short, any content which is highly time-sensitive, or which varies depending on the particulars of the request that are not covered by HTTP negotiation, should not be cached.
@@ -280,13 +268,11 @@If on the other hand, the content served differs depending on the values of various HTTP headers, it is possible that it might be possible to cache it intelligently through the use of a "Vary" header.
-If a response with a "Vary" header is received by
mod_cache when requesting content by the backend it
will attempt to handle it intelligently. If possible,
@@ -303,7 +289,6 @@ Vary: negotiate,accept-language,accept-charset
mod_cache will only serve the cached content to
requesters with matching accept-language and accept-charset headers
matching those of the original request.
As requests to end-users can be served from the cache, the cache
itself can become a target for those wishing to deface or interfere with
content. It is important to bear in mind that the cache must at all
@@ -332,15 +316,12 @@ Vary: negotiate,accept-language,accept-charset
using mod_disk_cache you should bear this in mind -
ensure you upgrade Apache when security upgrades are announced and
run CGI processes as a non-Apache user using suEXEC if possible.
When running Apache as a caching proxy server, there is also the potential for so-called cache poisoning. Cache Poisoning is a broad term for attacks in which an attacker causes the proxy server to @@ -358,7 +339,6 @@ Vary: negotiate,accept-language,accept-charset a series of requests, and to exploit a vulnerability on an origin webserver such that the attacker can entirely control the content retrieved by the proxy.
-The most basic form of caching present in Apache is the file-handle
caching provided by mod_file_cache. Rather than caching
file-contents, this cache maintains a table of open file descriptors. Files
@@ -406,13 +385,11 @@ Vary: negotiate,accept-language,accept-charset
will have been deleted, and not show up on the filesystem, extra free
space will not be recovered until Apache is stopped and the file
descriptor closed.
mod_mem_cache also provides its own file-handle
caching scheme, which can be enabled via the
CacheEnable directive.
As with all of mod_cache this type of file-handle
caching is intelligent, and handles will not be maintained beyond
the expiry time of the cached content.
Almost all modern operating systems cache file-data in memory managed directly by the kernel. This is a powerful feature, and for the most part operating systems get it right. For example, on Linux, let's look at @@ -482,7 +456,6 @@ sys 0m0.000s
Despite the performance and advantages of automatic operating system @@ -497,7 +470,6 @@ sys 0m0.000s
mod_file_cache provides the
MMapStatic directive, which
allows you to have Apache map a static file's contents into memory at
@@ -517,14 +489,11 @@ sys 0m0.000s
process will replicate this memory, so it is critically important
to ensure that the files mapped are not so large as to cause the
system to swap memory.
mod_mem_cache provides a HTTP-aware intelligent
in-memory cache. It also uses heap memory directly, which means that
even if MMap is not supported on your system,
@@ -538,9 +507,6 @@ CacheEnable mem /
# Limit the size of the cache to 1 Megabyte
MCacheSize 1024
-
-
To store items in the cache, mod_disk_cache creates
a 22 character hash of the url being requested. Thie hash incorporates
the hostname, protocol, port, path and any CGI arguments to the URL,
@@ -622,13 +587,11 @@ CacheDirLength 1
".vary" directory will be created for the url in question. This
directory will have multiple ".data" files corresponding to the
differently negotiated content.
Although mod_disk_cache will remove cached content
as it is expired, it does not maintain any information on the total
size of the cache or how little free space may be left.
When caching locally generated content, ensuring that
On can dramatically improve the ratio of cache hits. This
@@ -156,13 +154,11 @@
If you are using Server Side Includes, and want the benefit of speedy
serves from the cache, you should use virtual include
types.
The default expiry period for cached entities is one hour, however
this can be easily over-ridden by using the
The maximum expiry period may also be controlled by using the
When content expires from the cache and is re-requested from the backend or content provider, rather than pass on the original request, Aoache will use a conditional request instead.
@@ -222,13 +216,11 @@ from the cache if it has not changed. As long as reading from the cache store is faster than reading from the backend (e.g. an in-memory cache compared to reading from disk). -As mentioned already, the two styles of caching in Apache work
differently,
In short, any content which is highly time-sensitive, or which varies depending on the particulars of the request that are not covered by HTTP negotiation, should not be cached.
@@ -301,13 +289,11 @@If on the other hand, the content served differs depending on the values of various HTTP headers, it is possible that it might be possible to cache it intelligently through the use of a "Vary" header.
-If a response with a "Vary" header is received by
As requests to end-users can be served from the cache, the cache itself can become a target for those wishing to deface or interfere with content. It is important to bear in mind that the cache must at all @@ -354,15 +338,12 @@ Vary: negotiate,accept-language,accept-charset ensure you upgrade Apache when security upgrades are announced and run CGI processes as a non-Apache user using suEXEC if possible.
-When running Apache as a caching proxy server, there is also the potential for so-called cache poisoning. Cache Poisoning is a broad term for attacks in which an attacker causes the proxy server to @@ -380,7 +361,6 @@ Vary: negotiate,accept-language,accept-charset a series of requests, and to exploit a vulnerability on an origin webserver such that the attacker can entirely control the content retrieved by the proxy.
-The most basic form of caching present in Apache is the file-handle
caching provided by
As with all of
Almost all modern operating systems cache file-data in memory managed directly by the kernel. This is a powerful feature, and for the most part operating systems get it right. For example, on Linux, let's look at @@ -529,7 +503,6 @@ sys 0m0.000s deleted or modified, it can automatically remove file contents from the cache when neccessary. This is a big advantage over Apache's in-memory caching which has no way of knowing when a file has changed.
-Despite the performance and advantages of automatic operating system
@@ -544,7 +517,6 @@ sys 0m0.000s
To store items in the cache, Although