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
This commit is contained in:
Sebastian Grewe 2013-07-02 14:30:07 +02:00
parent 6632920fa1
commit e9311f08a5
3 changed files with 17 additions and 8 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/public/include/config/global.inc.php
/public/templates/compile/*.php
/cronjobs/logs/*.txt
/public/templates/cache/*.php

View File

@ -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;
?>

View File

@ -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";
?>