Configuring MKDoc::Apache_Cache

A cache is a temporary store for documents that allows them to be quickly retrieved and served repeatedly – The purpose is to prevent a situation where repeated requests for a web address URI causes the server to duplicate effort fetching and reassembling data from various sources.

MKDoc has an internal cacheing mechanism at the document level. Authors can state how long they intend information in a document to stay current – This method is now deprecated in favour of a site-wide policy for cacheing all data, not just documents.

Cache Policies

As an example, a cache policy might say that articles are unlikely to change rapidly and can therefore be cached for a long time, however a news headlines page may change all the time and needs as little cacheing as is practical.

The policy for an MKDoc site can be tweaked to suit any such situation, but a basic policy will suffice for all but the most high-traffic situations. The policy is defined in a MKDoc::Control_List file like this:

Feel free to download and customise this default policy for your particular installation.

Installation

Note that MKDoc::Apache_Cache is an all-purpose accelerator for any mod_perl appplication that uses Apache::Registry. These instructions are for the MKDoc CMS, but can easily be customised to suit other software.

You need to retrieve and install MKDoc::Apache_Cache from CPAN, this is a standard perl module and can be installed normally. You may find that additional modules are required depending on your system:

Configuration

You now need to configure MKDoc to use the module and the policy.

Download the policy file and place in your MKDoc site directory. Make sure it is readable by the web-server user-account:

/var/www/mkdoc/example.com/cache-policy.txt

Open the httpd-mkdoc.conf file in an editor and locate this line:

PerlHandler Apache::Registry

Replace it with the following lines:

PerlSetEnv  MKDoc_Apache_Cache_CONFIG     /var/www/mkdoc/example.com/cache-policy.txt
PerlSetEnv  MKDoc_Apache_Cache_CACHE_ROOT /var/www/mkdoc/example.com/cache
PerlSetEnv  MKDoc_Apache_Cache_NAMESPACE  apache_cache_gz
PerlHandler MKDoc::Apache_Cache

Adjust the paths as necessary to suit your installation. Restart apache and test your site.

You can check that the cache is in effect for any document by looking at the HTTP response headers, two new headers will be in place:

Etag: f298648cd5372b9616e5445dde5f34e2
Expires: Thu, 26 Aug 2004 20:49:47 GMT

These headers are hints for further downstream caches.

Additional information

You may be interested in following-up the concepts and rationale behind web-cacheing. Mark Nottingham's Caching Tutorial for Web Authors and Webmasters is a good place to start.

Document Links

MKDoc::Apache_Cache from CPAN
Download the software in tar.gz format from here
http://search.cpan.org/~bpostle/MKDoc-Apache_Cache/
Caching Tutorial for Web Authors and Webmasters
Although technical in nature, this document attempts to make the concepts involved understandable and applicable in real-world situations
http://www.mnot.net/cache_docs/
This document was last modified on 2004-09-29 17:15:55.
MKDoc Ltd., 31 Psalter Lane, Sheffield, S11 8YL, UK.
Copyright © 2001-2005 MKDoc Ltd.