我在smarty模板里引入了其他的模板,比方说引入了a.html文件,结果smarty缓存不起作用了,每次访问都刷新,如果我不引入a.html文件就没什么问题,谁能知道这是怎么回事?该怎么解决啊

解决方案 »

  1.   

    这里牵扯到smarty的运行机制,我就不多解释了。在引用这个界面的时候不要 使用include
    要使用insert比如<!--{insert name="getBanner" file="a.html"}-->这样就可以解决缓存的问题了。
      

  2.   


    include_once("smartylib/Smarty.class.php"); //包含smarty类文件$smarty = new Smarty(); //建立smarty实例对象$smarty$smarty->config_dir="smartylib/Config_File.class.php";  // 目录变量$smarty->caching=false; //是否使用缓存,项目在调试期间,不建议启用缓存$smarty->template_dir = "./templates"; //设置模板目录-->>当前目录$smarty->template_dir = "../templates"; //设置模板目录-->>上级目录$smarty->compile_dir = "./templates_c"; //设置编译目录$smarty->cache_dir = "./smarty_cache"; //缓存文件夹//$smarty->caching = true;  //开启缓存,为flase的时侯缓存无效$smarty->cache_lifetime = 30;  //缓存时间(秒)//模板引用smarty开始结束符号
    $smarty->left_delimiter = "{";$smarty->right_delimiter = "}";第4行,要开启缓存,改为TRUE就行了。
      

  3.   

    用smarty开启缓存我还能不知道啊,哎,得了,不整这个了