如何判断 mod_deflate 是否真的有效?

Jay*_*Jay 6 gzip mod-deflate apache-2.2

我已将以下内容放入我的 http.conf 文件中:

# mod_deflate configuration
<IfModule mod_deflate.c>

# Restrict compression to these MIME types
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css

# Level of compression (Highest 9 - Lowest 1)
DeflateCompressionLevel 9

# Netscape 4.x has some problems.
BrowserMatch ^Mozilla/4 gzip-only-text/html

# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip

# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

<IfModule mod_headers.c>
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>

</IfModule>
Run Code Online (Sandbox Code Playgroud)

我的内容没有返回 gzip 类型的 Content-Encoding,但我发现自己收到了更多 304,并且 Etag 附加了 +gzip 后缀。mod_deflate 真的在做它的工作吗?(对不起 n00b-ishness)

Mic*_*eld 10

标头告诉您什么,如果它没有返回“内容编码:gzip”,则可能无法正常工作..您可以按如下方式进行测试:

curl -I -H 'Accept-Encoding: gzip,deflate' http://yoursite.com/somefile
Run Code Online (Sandbox Code Playgroud)