From e9311f08a53912ea8b2a491124345b5fa11ed1b1 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 2 Jul 2013 14:30:07 +0200 Subject: [PATCH] Adding cache lifetime option to smarty config * Renamed configuration array to `smarty` => `cache` * Added `smarty` => `cache_lifetime` to expire cache files properly This should be safe to use, be aware that each page request is cached! That includes any POST/GET calls to the site. It does help in speeding up the site, up to 100% on some requests. For a high traffic site it probably makes sense to enable this option with a low cache lifetime to ensure most recent data. Addresses #309 --- .gitignore | 1 + public/include/config/global.inc.dist.php | 21 ++++++++++++++------- public/include/smarty.inc.php | 3 ++- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 66b6c501..a8f1b1ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /public/include/config/global.inc.php /public/templates/compile/*.php /cronjobs/logs/*.txt +/public/templates/cache/*.php diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index 8bff1114..da41eb90 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -358,13 +358,20 @@ $config['cookie']['domain'] = ''; * * Ensure that the folder `templates/cache` is writable by the webserver! * - * Options: - * 0 = disabled - * 1 = enabled + * cache = Enable/Disable the cache + * cache_lifetime = Time to keep files in seconds before updating them * - * Default: - * 0 = disabled + * Options: + * cache: + * 0 = disabled + * 1 = enabled + * cache_lifetime: + * time in seconds + * + * Defaults: + * cache = 0, disabled + * cache_lifetime = 30 seconds **/ -$config['cache'] = 0; - +$config['smarty']['cache'] = 1; +$config['smarty']['cache_lifetime'] = 30; ?> diff --git a/public/include/smarty.inc.php b/public/include/smarty.inc.php index 8a320581..46a38750 100644 --- a/public/include/smarty.inc.php +++ b/public/include/smarty.inc.php @@ -20,6 +20,7 @@ $smarty->template_dir = BASEPATH . 'templates/' . THEME . '/'; $smarty->compile_dir = BASEPATH . 'templates/compile/'; // Optional smarty caching, check Smarty documentation for details -$smarty->caching = $config['cache']; +$smarty->caching = $config['smarty']['cache']; +$smarty->cache_lifetime = $config['smarty']['cache_lifetime']; $smarty->cache_dir = BASEPATH . "templates/cache"; ?>