$cache_lifetime                function use_cache ( $key = '' )
                {
                        if (empty($_POST))
                        {
                                $this->cache_filename  =  $this->cache_dir . 'cache_' . md5($_SERVER['REQUEST_URI'] . serialize($key)) . '.ser';
                                if (($_SERVER['HTTP_CACHE_CONTROL'] != 'no-cache')  &&  ($_SERVER['HTTP_PRAGMA'] != 'no-cache')  &&  @is_file($this->cache_filename))
                                {
                                        if ((time() - filemtime($this->cache_filename)) < $this->cache_lifetime)
                                        {
                                                readfile($this->cache_filename);
                                                exit;
                                        }
                                }
                                ob_start( array( &$this, 'cache_callback' ) );
                        }
                }

解决方案 »

  1.   

    这个函数我昨晚在家已琢磨过,现在发现之所以老是重建,是因为其中的$_SERVER['HTTP_CACHE_CONTROL']老是=no-cache ,今天到单位的机器上一试,这个值又为空了,缓存开始生效。难道我的服务器环境有什么不同吗?同样是win+apache
    谢谢
      

  2.   

    $_SERVER['HTTP_CACHE_CONTROL']由什么左右?在何处设置呢
      

  3.   

    no-cache 是不缓存,一般通过发送头设置
    如果没有发送不缓存指令,则可能是你的浏览器禁用了缓冲区