PEAR Cache is an excellent package that allows you to cache function calls, output, and more

Simple Output caching using PEAR::Cache
<?php
    require_once('Cache/Output.php');

    /* Create a new instance of the output cache,
       storing as a file in the /tmp directory */    
    $cache = new Cache_Output('file',
                              array('cache_dir' => '/tmp'));
    
    /* Generate the ID for the cached content based on the
       values which effect the output of the page. */
    $cache_id = $cache->generateID(array('url' => $_SERVER['REQUEST_URI'],
                                         'post' => $_POST));
                                         
    /* Begin the cache by checking if this version of the
       content has already been cached or not. */
    if($content = $cache->start($cache_id)) {
    
        echo $content;
        exit;
    
    }
    
    /* Generate the content to be cached */
    
    /* Cache the content and display it for this request */
    echo $cache->end();    
?>