运用header 让php程序被浏览器缓存


if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && (time()-strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) < 3600*24)) {
     header(“HTTP/1.1 304 Not Modified”);
     exit;
   }
   header(“Last-Modified: ” . gmdate(‘D, d M Y H:i:s \G\M\T’, time()) );

expires:不大好用,直接敲还是会访问,这个虽然占服务器连接,但是至少他304,后面的不执行了。

  1. #1 by vaal.water - June 2nd, 2010 at 17:11

    Cache-control: max-age=300 设置缓存时间浏览器就不去服务器查了

  2. #2 by Albert - June 8th, 2010 at 15:06

    ….不好用,你设置一下,f5一下,就会发现他还是发请求过来,(不用ctrl+f5)

(will not be published)

  1. No trackbacks yet.