好像还有一个类似debug=on之类的参数。如果在debug状态,是不管cache状态的。

解决方案 »

  1.   

    如果设置为cache为true的话,对同一页面就会读取cache了.比如说index.php?id=1 index.php?id=2 这样内容是一样的.
    如果想不一样,就要在$smarty->display('index.php', $_GET['id]);另外,如果要把cache设置为true的话,一定要定期清除cache.
      

  2.   

    你要设置
    $smarty->cache_dir= 'templates_c';//里面你自己的路径
    第一次的时候$smarty->is_cached('index.tpl')是false,缓存一次下一次就是true了
      

  3.   

    楼上可能没有明白我的意思。我意思是,//如果没有缓存,那么 进if语句 给数据赋值  
    if(!$smarty->is_cached('index.tpl')) 
    {    
    //为什么这个地方每次都会输出 我上面不是有一个判断的语句吗?
    echo "cache"; 
    $contents = "kkk";    
    $smarty->assign("content",$contents);    
    } 现在我cache的文件夹里面已经有缓存xxindex.html了。
    应该不会进这个条件语句才对啊。
      

  4.   

    不管我刷新多少次总是会echo 出 cache
      

  5.   

    if(!$smarty->is_cached('index.tpl'))
    那就看你判定的是index.tpl还是index.html哪?
      

  6.   

    这么低级的错误。晕哦。我说怎么回事呢。。co代码co多了。
    深刻检讨
      

  7.   

    在我的机器上, is_cached是可以正常工作的.请确定cache目录是否正确,以及目录的权限设置
      

  8.   

    上面的问题解决了,再提一个问题。require "./inc/class/smarty-tpl.php";
    require "./inc/class/db.php";$smarty->caching = true; 
    $db = new Db();
    if(!$smarty->is_cached('index.html'))
    {     
    $contents = $db->fetchAll("SELECT username FROM user LIMIT 0,110");
    $smarty->assign("content",$contents);     
    }$smarty->display("index.html");如果  我缓存了数据之后。再数据库里面再插入一条新的数据,那么应该怎么做呢?
      

  9.   

    $smarty->clear_cache(...);
    还能接到分吗?lz