my $cache=Cache::FileCache->new(); #options here. . . my $cache_key=$id; #Cache key that uniquely identifies this page my $object=$cache->get($cache_key); my $output; if( not defined $object){ # The page isn't in the cache, or it's expired. # Create your page, piping it through HTML::Template. $cache->set($cache_key,$object,'2 hours'); } else { # The page is in the cache. $output=$object; } print $object;