从PHP处理器缓存css / js

时间:2010-10-08 02:05:54

标签: php caching

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

.htaccess重写css和js文件以指向处理器。

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

由于某种原因,css和js文件拒绝缓存? 我设置了“Expires”和“Cache-Control”标题,但仍然没有运气。

有什么建议吗?

由于

修改

以下是一些代码:

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");
}

我正在使用Google 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 个答案:

没有答案