我创建了一个将采用css(或javascript)文件并将其作为一个文件输出的页面。我注意到当我使用ob_gzhandler
压缩输出时,Firefox和Internet Explorer都无法发送“If-Modified-Since”标头:
if(!ob_start("ob_gzhandler")) ob_start();
初始标题(样本中主机和引荐来源已更改):
Response Headers
Cache-Control public, must-revalidate, maxage=4838400
Connection keep-alive
Content-Encoding gzip
Content-Length 87281
Content-Type text/css; charset: UTF-8
Date Wed, 12 Dec 2012 16:04:32 GMT
Expires Wed, 06 Feb 2013 16:04:32 GMT
Last-Modified Fri, 12 Oct 2012 13:47:18 GMT
Pragma public
Server Apache
Vary Accept-Encoding
X-Cache MISS from localhost
X-Powered-By PHP/5.3.13
Request Headers
Accept text/css,*/*;q=0.1
Accept-Encoding gzip, deflate
Accept-Language en-gb,en;q=0.5
Authorization Basic cmVkZnVzZTpyM2RmdXMz
Cache-Control no-cache
Connection keep-alive
Cookie PHPSESSID=e73355c49f06a059c22d7f02687dc51b
DNT 1
Host example.com
Pragma no-cache
Referer http://example.com/
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0
刷新时发送以下标题(示例中主机和引用更改):
Response Headers
Cache-Control public, must-revalidate, maxage=4838400
Connection keep-alive
Content-Encoding gzip
Content-Length 87245
Content-Type text/css; charset: UTF-8
Date Wed, 12 Dec 2012 16:09:11 GMT
Expires Wed, 06 Feb 2013 16:09:11 GMT
Last-Modified Fri, 12 Oct 2012 13:47:18 GMT
Pragma public
Server Apache
Vary Accept-Encoding
X-Cache MISS from localhost
X-Powered-By PHP/5.3.13
Request Headers
Accept text/css,*/*;q=0.1
Accept-Encoding gzip, deflate
Accept-Language en-gb,en;q=0.5
Authorization Basic cmVkZnVzZTpyM2RmdXMz
Cache-Control max-age=0
Connection keep-alive
Cookie PHPSESSID=e73355c49f06a059c22d7f02687dc51b
DNT 1
Host example.com
Referer example.com
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20100101 Firefox/17.0
如果我从使用ob_gzhandler
切换到标准ob_start()
,那么它可以正常工作并在第二次加载时按预期返回304。
我认为另一个与之相关的问题是,从Android设备查看时,css不适用于股票浏览器或Dolphin Browser,但适用于Android版Firefox。通过禁用ob_gzhandler