代码之家  ›  专栏  ›  技术社区  ›  Emmanuel

从PHP处理器缓存css/js

  •  1
  • Emmanuel  · 技术社区  · 16 年前

    我已经构建了一个php处理器来处理所有css和js文件。

    处理器获取css/js文件的内容,对其进行处理,然后输出到浏览器。

    出于某种原因css和js文件拒绝缓存?

    谢谢

    下面是一些代码:

    function setExpires($expires) {  
     header('Expires: '.gmdate('D, d M Y H:i:s', time()+$expires).' GMT');  
     header("Cache-Control: max-age=$expires, public");
     header("Connection: close");
    }
    

    我正在使用谷歌Chrome开发工具。返回的标题如下:

    Request URL:http://www.static.do-u-know.net/css/common.1286502074.css
    Request Method:GET
    Status Code:200 OK
    
    Request Headers
    Accept:text/css,*/*;q=0.1
    Cache-Control:max-age=0
    Referer:http://www.do-u-know.net/frame.php
    User-Agent:Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3
    
    Response Headers
    Cache-Control:max-age=631138519, public
    Connection:close
    Content-Encoding:gzip
    Content-Type:text/css
    Date:Fri, 08 Oct 2010 02:41:12 GMT
    Expires:Mon, 07 Oct 2030 22:56:31 GMT
    Server:Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
    Transfer-Encoding:chunked
    Vary:Accept-Encoding
    X-Powered-By:PHP/5.2.5
    
    0 回复  |  直到 16 年前
    推荐文章