Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I pre-load my templates using cache-mode and mod_perl?

mod_perl pre-load Templates
0
Posted

How can I pre-load my templates using cache-mode and mod_perl?

0

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.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123