Bug 7511 [ENH] Template caching (T::T feature)
authorPaul Poulain <paul.poulain@biblibre.com>
Fri, 10 Feb 2012 08:45:34 +0000 (09:45 +0100)
committerPaul Poulain <paul.poulain@biblibre.com>
Mon, 13 Feb 2012 10:01:46 +0000 (11:01 +0100)
Just add to your Koha configuration file
<template_cache_dir>/path/writable/by/apache/user</template_cache_dir>
in the <config> block, and Koha will use template caching, for about
10% CPU time saving.

on linux servers, /tmp is usually OK

(also fixes an indenting with a TAB)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
The results of using this are very striking. Based on an insufficient
sample size, it would seem that the time spent in T::T is reduced by a
factor of at least 5.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
C4/Templates.pm

index d150a16..0741040 100644 (file)
@@ -53,12 +53,13 @@ sub new {
     else {
         $htdocs = C4::Context->config('intrahtdocs');
     }
-
     my ($theme, $lang)= themelanguage( $htdocs, $tmplbase, $interface, $query);
     my $template = Template->new(
         {   EVAL_PERL    => 1,
             ABSOLUTE     => 1,
-           PLUGIN_BASE => 'Koha::Template::Plugin',
+            PLUGIN_BASE => 'Koha::Template::Plugin',
+            COMPILE_EXT => C4::Context->config('template_cache_dir')?'.ttc':'',
+            COMPILE_DIR => C4::Context->config('template_cache_dir')?C4::Context->config('template_cache_dir'):'',,
             INCLUDE_PATH => [
                 "$htdocs/$theme/$lang/includes",
                 "$htdocs/$theme/en/includes"