Here are some incomplete and probably incorrect notes about PHP caching options.
Page-level caching works well for page views that don’t change very often. For example, a front page which rotates the featured articles every hour could be page-cached, then invalidated each hour.
Region-level caching can be used to pull some parts of an otherwise dynamic page from a cache.
Object-level caching can store structured PHP data objects, so that they don’t have to be built with each run.
These levels of cache are ordered by increasing “ickiness”.
PHP-Level
- Cache Lite is a PHP module available through PEAR which allows object caching with pluggable backend (file, memcached).
- Drupal’s builtin cache system, documented at api.drupal.org, provides an interface similar to the Cache Lite API: to put serialized data in the cache, just call cache_set with a unique key for the item. Data can be cached permenantly, temporarily, or with a timestamp for expiration.
Webserver
PHP can spit out static versions of pages it serves. The webserver can then check for a cached version before invoking PHP at all. This is gobs faster than PHP-level checks. Jeremy and Matt have this implentation for Drupal.
Lighttpd’s mod_magnet can do region-level caching in the webserver. Cool! Too bad you Apache sods :P
