可以同过设置smarty的参数来实现,比如:
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->caching = true;// 设置cache可用
$smarty->display('index.tpl');这样只需生成一次(会输出到指定的$cache_dir中,默认为"./cache"),然后你的两个模板文件如果不需要更新(比如top.php和foot.php),那么系统再次调用时,将会直接引用缓存中的相应文件。其缓存文件的有效期为$cache_lifetime所设定的,默认是3600s。
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->caching = true;// 设置cache可用
$smarty->display('index.tpl');这样只需生成一次(会输出到指定的$cache_dir中,默认为"./cache"),然后你的两个模板文件如果不需要更新(比如top.php和foot.php),那么系统再次调用时,将会直接引用缓存中的相应文件。其缓存文件的有效期为$cache_lifetime所设定的,默认是3600s。
在没有发布前 最好不要使用缓存 。