How can I pre-load my templates using cache-mode and mod_perl?
use HTML::Template; use File::Find; print STDERR “Pre-loading HTML Templates…\n”; find( sub { return unless /\.tmpl$/; HTML::Template->new( filename => “$File::Find::dir/$_”, cache => 1, ); }, ‘/path/to/templates’, ‘/another/path/to/templates/’ ); Note that you’ll need to modify the “return unless” line to specify the extension you use for your template files – I use .tmpl, as you can see. You’ll also need to specify the path to your template files. One potential problem: the “/path/to/templates/” must be EXACTLY the same path you use when you call HTML::Template->new(). Otherwise the cache won’t know they’re the same file and will load a new copy – instead getting a speed increase, you’ll double your memory usage. To find out if this is happening set cache_debug => 1 in your application code and look for “CACHE MISS” messages in the logs.