dongqiu3254 2012-12-12 16:16
浏览 37

ob_gzhandler和CSS文件的问题

I've created a page that will take css (or javascript) files and output them as one file. I have noticed that Firefox and Internet Explorer will both fail to send the "If-Modified-Since" header at any time when I compress the output using ob_gzhandler:

if(!ob_start("ob_gzhandler")) ob_start();

The initial headers (Host and referrer changed in sample):

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

And the following headers are sent on refresh (Host and referrer changed in sample):

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

If I switch from using ob_gzhandler to a standard ob_start() then it works fine and returns a 304 as expected on the second load.

Another issue that I think is related is that when viewing from an android device, the css doesn't get applied for either the stock browser or for Dolphin Browser, but is fine for Firefox for Android. This is also resolved by disabling the ob_gzhandler

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 八爪鱼爬数据为什么自己停了
    • ¥15 交替优化波束形成和ris反射角使保密速率最大化
    • ¥15 树莓派与pix飞控通信
    • ¥15 自动转发微信群信息到另外一个微信群
    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率