你更改了数据当然是显示新的了。把你程序改一下。<?php
include_once("../etc/define.php");
require('Smarty.class.php');
$tpl = new Smarty;
$tpl->template_dir = __ROOT_TEMPLATES_TPATH.__SETTING_STYLE;
$tpl->compile_dir = __ROOT_TPLS_TPATH."templates_c/".__SETTING_STYLE;
$tpl->config_dir = __ROOT_TPLS_TPATH."configs/";
$tpl->cache_dir = __ROOT_TPLS_TPATH."cache/";
if($tpl->is_cached("testcache.tpl"))
{
$tpl->$tpl->display("testcache.tpl");
exit;
}$tpl->cache_lifetime = 60 * 60 * 24;
$tpl->caching = true; $tpl->assign("name", "abc"); $tpl->display("testcache.tpl");
?>
include_once("../etc/define.php");
require('Smarty.class.php');
$tpl = new Smarty;
$tpl->template_dir = __ROOT_TEMPLATES_TPATH.__SETTING_STYLE;
$tpl->compile_dir = __ROOT_TPLS_TPATH."templates_c/".__SETTING_STYLE;
$tpl->config_dir = __ROOT_TPLS_TPATH."configs/";
$tpl->cache_dir = __ROOT_TPLS_TPATH."cache/";
if($tpl->is_cached("testcache.tpl"))
{
$tpl->$tpl->display("testcache.tpl");
exit;
}$tpl->cache_lifetime = 60 * 60 * 24;
$tpl->caching = true; $tpl->assign("name", "abc"); $tpl->display("testcache.tpl");
?>
这句打错了
$tpl->display("testcache.tpl");
不过从你的表述上来看,就应该是这样的
你说“但是如果修改abc为cba,上传以后刷新,并没有看到想象中的abc,而是更新到了cba。”
看看连程序都改动了,老程序的“缓存”还有意义吗?
$tpl->force_compile = false;<?php
include_once("../etc/define.php");
require('Smarty.class.php');
$tpl = new Smarty;
$tpl->template_dir = __ROOT_TEMPLATES_TPATH.__SETTING_STYLE;
$tpl->compile_dir = __ROOT_TPLS_TPATH."templates_c/".__SETTING_STYLE;
$tpl->config_dir = __ROOT_TPLS_TPATH."configs/";
$tpl->cache_dir = __ROOT_TPLS_TPATH."cache/";$tpl->cache_lifetime = 60 * 60 * 24;
$tpl->caching = true;
$tpl->force_compile = false; $tpl->assign("name", "abc"); $tpl->display("testcache.tpl");
?>
并且cache没有过期。因为模板不修改,smarty就不会重新编译文件(force_complie=false)。
所以$tpl->force_complie = false;不允许强制编译文件。在开发和调试时把它设置为true,便于
查看运行结果。