Caching Directives

Several directives control the caching behavior of the server. A cache is a locally maintained copy of a server's web page. When firewalls are used, direct web access is often blocked. Users connect to a proxy server through the local network, and the proxy server is trusted to connect to the remote web server. Proxy servers do not have to maintain cached copies of web pages, but caching improves performance by reducing the amount of traffic sent over the WAN and by reducing the contention for popular websites. The directives that control caching behavior are as follows:

ProxyRequests Setting this option to on turns your server into a proxy server. By default, this is set to off.

ProxyVia Enables or disables the use of Via: headers, which aid in tracking where cached pages actually came from.

CacheRoot Defines the directory in which cached web pages are written. To avoid making the directory writable by the user nobody, create a special user ID for httpd when you run a proxy server.

CacheSize Defines the maximum size of the cache in kilobytes. The default is 5KB, which is a very minimal size. Many system administrators consider 100MB a more reasonable setting.

CacheGcInterval Defines the time interval at which the server prunes the cache. It is defined in hours, and the default is 4. Given the defaults, the server prunes the cache down to 5 kilobytes every four hours.

CacheMaxExpire Defines the maximum number of hours a document is held in the cache without requesting a fresh copy from the remote server. The default is 24 hours. With the default, a cached document can be up to a day out-of-date.

CacheLastModifiedFactor Defines the length of time a document is cached, based on when it was last modified. The default factor is 0.1. Therefore, if a document is retrieved that was modified 10 hours ago, it is held in the cache for only one hour before a fresh copy is requested. The assumption is that if a document changes frequently, the time of its last modification will be recent. Thus, documents that change frequently are cached only a short period of time. Regardless, nothing is cached longer than CacheMaxExpire.

CacheDefaultExpire Defines a default cache expiration value for protocols that do not provide the value. The default is one hour.

NoCache Defines a list of the hostnames of servers whose pages you do not want to cache. If you know that a server has constantly changing information, you don't want to cache information from that server because your cache will always be out-of-date. Listing the name of that server on the NoCache directive line means that queries are sent directly to the server, and responses from the server are not saved in the cache.

Was this article helpful?

0 0

Post a comment