Apache不发送304响应(如果mod_deflate模块和AddOutputFilterByType启用) [英] Apache is not sending 304 response (if mod_deflate and AddOutputFilterByType is enabled)

查看:651
本文介绍了Apache不发送304响应(如果mod_deflate模块和AddOutputFilterByType启用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我添加了以下行,我的Apache httpd.conf: -

I have added the following line in my Apache httpd.conf: -

AddOutputFilterByType DEFLATE text/html text/css application/javascript application/x-javascript application/json

我有一个脚本包含一个HTML文件(test.html的): -

I have a html file (test.html) with a script inclusion: -

<script type="text/javascript" src="/test.js"></script>

问题是,每次我打开test.html的时间,test.js还装有HTTP状态码:200

The problem is, every time I load test.html, test.js is also loaded with HTTP status: 200.

现在的问题是:为什么有条件的GET不满意

如果我注释掉在httpd.conf中的AddOutputFilterByType行,阿帕奇发送304。

If I comment out the "AddOutputFilterByType" line in httpd.conf, Apache sends 304.

如果我能在httpd.conf AddOutputFilterByType,请求头是: -

If I enable AddOutputFilterByType in httpd.conf, the request header is: -


Host: optimize
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 GTB5 (.NET CLR 3.5.30729) FirePHP/0.2.4
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://optimize/
Cookie: PHPSESSID=nbq6h0eeahkshkcbc6ctu2j2b4
If-Modified-Since: Tue, 19 May 2009 07:06:46 GMT
If-None-Match: "2000000000717f-2c25a-46a3e8dcc2ad8"-gzip
Cache-Control: max-age=0

和响应标题是: -

And the response header is: -


Date: Fri, 22 May 2009 07:03:40 GMT
Server: Apache/2.2.9 (Win32) PHP/5.2.6
Last-Modified: Tue, 19 May 2009 07:06:46 GMT
Etag: "2000000000717f-2c25a-46a3e8dcc2ad8"-gzip
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 52583
Keep-Alive: timeout=5, max=98
Connection: Keep-Alive
Content-Type: application/javascript

更新:我注意到,如果我禁用ETag的,它工作正常。我的意思是它发送304。

UPDATE: I have noticed, if I am disabling ETag, it works properly. I mean it sends 304.

FileETag None

但我真的想保持ETag的,因为它是(我知道有一个索引节点披露问题)。

But I really want to keep ETag as it is (I know that there is a inode disclosure issue).

推荐答案

这是Apache的一个已知的bug。请参见 Apache的错误#45023 和的阿帕奇304的ETag和mod_deflate模块总结。

This is a known bug in Apache. See Apache bug #45023, and summary of Apache 304 etags and mod_deflate.

从SVN重建将解决这个问题。该决议是恢复该附加-gzip到ETAG的变化。然而,也有相关的HTTP遵守问题

Rebuilding from svn will fix the issue. The resolution was to revert the change that appended "-gzip" to the etag. However, there are associated HTTP compliance problems.

如果您无法重建的Apache,有一个在错误报告建议运行时配置的解决方法:

If you can't rebuild Apache, there is a suggested runtime configuration workaround in the bug report:

 RequestHeader  edit "If-None-Match" "^\"(.*)-gzip\"$" "\"$1\""
 Header  edit "ETag" "^\"(.*[^g][^z][^i][^p])\"$" "\"$1-gzip\""

这篇关于Apache不发送304响应(如果mod_deflate模块和AddOutputFilterByType启用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆