1.php
//建立缓存
<php
//包含Smarty类库
$require("libs/Smarty.class.php");
//创建Smarty类的对象
$smarty = new Smarty;
//启用缓存
//caching 默认情况下为0,或无效,如果模版产生冗余,建议打开缓存,这样有利于得到良好的性能增益。也可以一个模版设有多个缓存:当值为1或2时启动缓存
$smarty ->caching = 2;
//设置缓存时间,以秒为单位
$smarty->cache_lifetime=60*60;
//指定缓存文件保存的目录
$smarty->cache_dir = "./cache";
//输出保存
$smarty ->display(index.html);
?>