我在smarty模板中引入inc文件,为什么缓存会失效,如果去了的话就没问题了,但是我必须要引入inc文件啊,改怎么处理,求高手解答

解决方案 »

  1.   

    <div class="wrapper clearfix <{if $mt10}>mt10<{/if}>">
     <!--左侧文章 start-->
      <div class="wrap_l">
        <!--文章列表-->
        <{$articleStr}>
        <{if $focusPicShow}>
        <{include file="../Caches/FirstIndex.tpl"}>
        <{/if}>
        <!--翻页-->
        <{$more}>
        <!--热门专题推荐-->
        <{$HotTopicModuleStr}>
      </div>
      
     <!--左侧文章 end-->
     <!--右侧栏目 start-->
        <{include file="../Caches/ListRight.tpl"}>
     <!--右侧栏目 end-->
    </div>
    <!-- Baidu Button BEGIN -->
    <script type="text/javascript" id="bdshare_js" data="type=slide&amp;img=6&amp;uid=156901" ></script>
    <script type="text/javascript" id="bdshell_js"></script>
    <script type="text/javascript">
    var bds_config = {'bdTop':280};
    document.getElementById("bdshell_js").src = "http://bdimg.share.baidu.com/static/js/shell_v2.js?t=" + new Date().getHours();
    </script>部分代码如上所示,只要把<{include file="../Caches/ListRight.tpl"}>去掉就不会一直刷新缓存了,可如果加了,每次访问都会刷新缓存,这是为什么啊?
      

  2.   

    现在的主要原因就是包含了inc文件所引起的,代码如下:
    <a class="fanhui" href="javascript:void(0);" id="goTopBtn" target="_self" style="display:none;"></a>
    <!--main end-->
    <!--ad-->
    <{if $focusPicShow}>
    <div class="ad wrapper"><{include file="../../include/index_hottopic_bottom.inc"}></div>
    <div class="ad5 wrapper"><{include file="../../include/index_friendlink_top.inc"}></div>

    <{/if}>
    <!--友情链接 start-->
    <{$friendLinkStr}>只要把
    <div class="ad wrapper"><{include file="../../include/index_hottopic_bottom.inc"}></div>
    <div class="ad5 wrapper"><{include file="../../include/index_friendlink_top.inc"}></div>
    去掉就什么问题都没了,这要怎么解决,还请高手给个意见啊
      

  3.   

    谢谢各位的支持,这问题已经解决了,换了个方法,
    <div class="ad wrapper"><{insert name="getBanner"file="../../include/index_hottopic_bottom.inc"}></div>
    <div class="ad5 wrapper"><{insert name="getBanner"file="../../include/index_friendlink_top.inc"}></div>
    不过我以前直接用include 也可以解决,可现在确不能用了,有点小郁闷
      

  4.   

    又遇到个问题哈,我用了insert 这个方法后,在getBanner这个方法中我还得用file_get_contents或readfile把模板中的内容读出来再返回数据,可是这样我感觉效率低啊,有没有好的办法不需要符文件啊,我的方法如下,能不能改进一下,调高效率:
    function insert_getBanner($params){//处理广告
    $content = @file_get_contents($params['file']);
    return $content;
    }