NAME Template::Plugin::Cache - cache output of templates SYNOPSIS [% USE cache = Cache%] [% cache.inc( 'template' => 'slow.html', 'keys' => {'user.name' => user.name}, 'ttl' => 360 ) %] DESCRIPTION The Cache plugin allows you to cache generated output from a template. You load the plugin with the standard syntax: [% USE cache = Cache %] This creates a plugin object with the name 'cache'. You may also specify parameters for the File::Cache module, which is used for storage. [% USE mycache = Cache(namespace => 'MyCache') %] The only methods currently available are include and process, abbreviated to "inc" and "proc" to avoid clashing with built-in directives. They work the same as the standard INCLUDE and PROCESS directives except that they will first look for cached output from the template being requested and if they find it they will use that instead of actually running the template. [% cache.inc( 'template' => 'slow.html', 'keys' => {'user.name' => user.name}, 'ttl' => 360 ) %] The template parameter names the file or block to include. The keys are variables used to identify the correct cache file. Different values for the specified keys will result in different cache files. The ttl parameter specifies the "time to live" for this cache file, in seconds. Why the ugliness on the keys? Well, the TT dot notation can only be resolved correctly by the TT parser at compile time. It's easy to look up simple variable names in the stash, but compound names like "user.name" are hard to resolve at runtime. I may attempt to fake this in a future version, but it would be hacky and might cause problems. AUTHORS Perrin Harkins (perrin@elem.com ) wrote the first version of this plugin, with help and suggestions from various parties. COPYRIGHT Copyright (C) 2001 Perrin Harkins. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. SEE ALSO Template::Plugin, File::Cache