How To Smarty Cache
by Root on Apr.14, 2009, under Php, smarty
Ok. If you use smarty and some part of your web site are no need to uptime any time, we can use the Smarty cache.
But smarty cache is not usefull for big project. But you can use in very simple let’s start.
First Prepare script for smarty.
require ‘kernel/libs/Smarty.class.php’; // This is my smarty class.
$smarty = new Smarty; //
$smarty->caching = true;
$smarty->cache_dir = "mycachedir/" where is cache?
if (!$smarty->is_cached(‘myspecial.tpl’)) {
$my_variable=”Hello World”;
$smarty->assign(‘exam_variable’,$my_variable);
}
$smarty->display(“myspecial.tpl”);
Ok. It’s finish. If you want to stop any part of script you can use $smarty->caching = false; for stop cache and restart again.
September 7th, 2009 on 13:30
This is not true, smarty cache is very useful, especially in big projects, since the loading time of big projects tends to be more important. You just need to do a little extra work and delete the cache (or even better, just the cache file of a specific file) after something was updated.
E.g. you use a funtion delete_cache($id); everytime someone saves an input to edit a page in your cms system.
September 14th, 2009 on 10:34