Caching
- Turn caching on
CacheRoot
- Set cache root directory for a proxy server
CacheSize
- Specify cache size (in megabytes)
NoCaching
- No caching for URLs matching a given mask
CacheOnly
- Cache only if URL matches a given set of URLs
CacheClean
- Remove everything older than this (in days)
CacheUnused
- Remove if has been unused this long (in days)
CacheDefaultExpiry
- Default expiry time if not given by remote server (in days)
CacheLastModifiedFactor
- Factor used in approximating expiry date
KeepExpired
- Store also expired documents for further efficiency
CacheRefreshInterval
- Guaranteed freshness of documents
CacheTimeMargin
- Time accuracy between hosts
CacheNoConnect
- Standalone cache mode - no external document retrievals
CacheExpiryCheck
- Turn off expiry checking for standalone operation
Gc
- Enable and disable garbage collection
GcDailyGc
- Time for daily garbage collection
GcMemUsage
- Garbage collector memory usage directive
CacheLimit_1
- First cache file size limit (kilobytes)
CacheLimit_2
- Second cache file size limit (kilobytes)
CacheLockTimeOut
- Break cache locks after this timeout
CacheAccessLog
- Log cache accesses to a different log file
Caching
directive:
Caching On
CacheRoot
directive, which is used to set the absolute
path of the cache directory:
CacheRoot /absolute/cache/directory
CacheSize
directive sets the maximum cache size in
megabytes. Default value is 5MB, but its preferable to have several
megabytes of cache, like 50-100MB, to get best results. Cache may,
however, temporarily grow a few megabytes bigger than specified.
CacheSize 20 Msets cache size to 20 megabytes.
NoCaching
directive
will never be cached, e.g.:
http://really.useless.site/*From version 3.0 on templates can have any number of wildcard characters
*
.
CacheOnly
directives will be cached, e.g.:
http://really.important.site/*From version 3.0 on templates can have any number of wildcard characters
*
.
CacheClean
directive will be removed.
This value overrides expiry date in that no file can be stored longer
than this value specifies, regardless of expiry date. Templates can
have any number of wildcard characters (asterisks).
CacheClean http://*.edu/* 1 month CacheClean http:* 3 weeks CacheClean ftp:* 14 days CacheClean gopher:* 5 days 12 hoursThe first matching
CacheClean
directive will be applied [this changed in
version 3.0pre4].
CacheUnused
directive will be removed.
Templates can have any number of wildcard characters (asterisks).
CacheUnused http://www.w3.org/* 7 days CacheUnused ftp://some.server/* 14 days CacheUnused * 4 days 12 hoursNote that the first matching specification will be applied; therefore HTTP files from
w3.org
will be
kept 7 days, and not 4.5 days. [The order was
vice-versa before the version 3.0pre4.]
Expires:
nor
Last-Modified:
header will be kept at most the time
specified by CacheDefaultExpiry
directive.
Default value is zero for all documents. With HTTP default should
be kept in zero (script replies shouldn't be cached); for FTP and
Gopher you migth consider expiry time such as 6 hours or 1 day.
Without this setting FTP and Gopher documents never get cached because
FTP and Gopher protocols don't have the notion of an expiry or last
modification time.
CacheDefaultExpiry ftp://ftp.w3.org/* 2 days CacheDefaultExpiry ftp:* 1 day CacheDefaultExpiry gopher:* 6 hours 30 minutesIn case of many
CacheDefaultExpiry
directives the first one that matches
will be used [this order was the opposite before the version
3.0pre4].
Default expiry for HTTP will
almost always cause problems because there are currently many scripts
that don't give an expiry date, yet their output expires immediately.
Therefore, it is better to keep the default value for
http:
in zero.
Last-Modified
time, but not Expires
time.
Last-Modified
can often be successfully used to
approximate expiry date. CacheLastModifiedFactor
gives
the fraction of time since last modification to give the remaining
time to be up-to-date.
Default value is 0.1
, which means that e.g. file modified
20 days ago will expire in 2 days.
CacheLastModifiedFactor 0.2would cause files modified 5 months ago to expire after one month.
This feature can be turned off by specifying:
CacheLastModifiedFactor Off
CacheLastModifiedFactor http://www.w3.org/httpd/* 0.10 CacheLastModifiedFactor http://www.w3.org/* 0.15 CacheLastModifiedFactor * 0.20
KeepExpired
directive On
the entire cache space is used up
efficiently, and files get removed only when space is needed for new
cache files:
KeepExpired On
CacheRefreshInterval
directive can be used to specify a cache refresh interval for URL's
matching a given pattern. This will cause httpd
to check
that the file is still up-to-date if more than the maximum allowed
time has passed since the last check, even if it would still seem to
be up to date according expiry date. Note that the cache refresh happens only if and when the document is requested, so if you have a refresh interval of 2 hours it doesn't mean that all the files in cache are fetched every two hours.
As a special case, specifying the refresh interval to be zero every cache access will cause a check to be made from remote server. This is ideal for users who need to have always the absolutely most up-to-date version, but still want faster response times and saves in network costs. This is still cheaper as all the checks are performed using the conditional GET request (with If-Modified-Since header), which sends the document only if it has changed, and otherwise tells the proxy to use the cache.
CacheRefreshInterval http://www.w3.org/httpd/* 1 day CacheRefreshInterval http://www.w3.org/* 5 days CacheRefershInterval http://weather.machine/* 2 hours CacheRefreshInterval * 1 week
CacheTimeMargin
defines this
time margin, by default:
CacheTimeMargin 2 minsNo document expiring in less than two minutes will be written to disk.
CacheNoConnect OnDefault setting is naturally
Off
.
This directive is typically used with expiry checking also turned
Off
.
CacheExpiryCheck
can be turned off:
CacheExpiryCheck OffDefault setting is
On
, meaning that proxy never returns an
expired document.
This is usually used in standalone cache
mode (CacheNoConnect
diretive turned
On
).
Gc
directive:
Gc Off
GcDailyGc time
GcDailyGc
specifies the time to do daily garbage
collection, normally during the night. Default value is 3:00.
Daily garbage collection can be disabled by specifying
Off
.
GcDailyGc 3:00Another example: turning daily gc off:
GcDailyGc Off
GcMemUsage
directive advices garbage collector about how
much memory to use. You may imagine this is the number of kilobytes
to use for gc data, but it may vary greatly according to dynamic
things, like the directory structure of cached files.
Default is 500; if gc fails because memory runs out make this smaller. If your machine has so much memory that it just can't run out, make this very big.
GcMemUsage 100if you have very little memory.
CacheLimit_1
sets the lower
limit; under this all the files have equal size factor.
CacheLimit_2
sets up higher limit; files bigger than this
get extremely bad size factor (meaning they get removed right away
because they are too big). Sizes are specified in kilobytes, and defaults values are 200K and 4MB, respectively.
CacheLimit_1 200 K CacheLimit_2 4000 Kwould set the same values as the defaults, 200K and 4MB.
CacheLockTimeOut
directive sets the amount of time after which lock can be broken.
Time is specified like all the other times in the configuration file, and
default value is 20 minutes, the same as default OutputTimeOut
.
CacheLockTimeOut should never be less than
OutputTimeOut!
CacheLockTimeOut 30 minswould set lock timeout to half an hour.