4.18 Page Caching

To improve performance, stories and their associated comments can be cached in the filesystem for anonymous users. Only story pages with comments are cached; index pages are still fully generated on each page request. Scoop maintains a timestamp for each cached page, and if there has been no change (ie, no comments posted) since the static page was generated, it is sent; if there has been a change, a new static page is generated and saved to the cache directory.

Generally speaking, a large proportion of site traffic is anonymous, so enabling static page caching will reduce the database load quite a bit. When traffic spikes, such as when a popular weblog posts a link to one of your stories, essentially all of the extra visitors will be anonymous--in this case, static page caching could be the difference between a very slow site and the database having a nervous breakdown.

To turn on static page caching, first create an empty directory fully writeable by the apache user. Enter the absolute filesystem path of that directory (with no trailing slash) in the variable page_path. Then, turn on the variable use_static_pages.

Keep in mind that Scoop does not manage the size of the cache, although it does delete old versions of the pages when regenerating them due to a change. Make sure you have plenty of free disk space available, and keep an eye on it; if the disks get full and Scoop (or rather, Apache) can't write to disk, things start breaking. Your users will often get page contained no data errors.

This is an Apache issue; Apache tends to have fits when it can't write to its log files. If Scoop's cache directory is on a separate partition, so that filling it up doesn't affect any files Apache needs to write to, Scoop will simply stop caching new pages and will happily run with those pages it has cached already. If you have a busy site, you should keep an eye on the page cache and delete pages that haven't been accessed in a long time, to free up space for pages that are still read frequently and would benefit the most from a cached version.


janra
2004-03-26