我目前像这样启用 GZIP:
# gzip compression
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript application/json
</ifmodule>
这会产生如下响应标头:
请注意,Content-Encoding
设置为gzip
,并且Vary
也设置了。
现在,我想使用这个 .htaccess 文件中的代码,据说可以提高性能,但是当我用这个替换上面的代码时:
# --------------------------------------------------------------------------------------
# Compression: http://code.google.com/speed/page-speed/docs/payload.html#GzipCompression
# --------------------------------------------------------------------------------------
<IfModule mod_deflate.c>
AddOutputFilter DEFLATE application/atom+xml
AddOutputFilter DEFLATE application/json
AddOutputFilter DEFLATE application/xhtml+xml
AddOutputFilter DEFLATE application/xml
AddOutputFilter DEFLATE text/css
AddOutputFilter DEFLATE text/html
AddOutputFilter DEFLATE text/plain
AddOutputFilter DEFLATE text/x-component
AddOutputFilter DEFLATE text/xml
# The following MIME types are in the process of registration
AddOutputFilter DEFLATE application/xslt+xml
AddOutputFilter DEFLATE image/svg+xml
# The following MIME types are NOT registered
AddOutputFilter DEFLATE application/mathml+xml
AddOutputFilter DEFLATE application/rss+xml
# JavaScript has various MIME types
AddOutputFilter DEFLATE application/javascript
AddOutputFilter DEFLATE application/x-javascript
AddOutputFilter DEFLATE text/ecmascript
AddOutputFilter DEFLATE text/javascript
# .ico files and other compressible images
AddOutputFilter DEFLATE image/vnd.microsoft.icon
AddOutputFilter DEFLATE image/x-icon
AddOutputFilter DEFLATE image/bmp
AddOutputFilter DEFLATE image/tiff
AddOutputFilter DEFLATE application/pdf
# compressible fonts (.woff is already compressed)
AddOutputFilter DEFLATE font/opentype
AddOutputFilter DEFLATE application/x-font-ttf
AddOutputFilter DEFLATE application/vnd.ms-fontobject
</IfModule>
同一文件请求的响应标头变为:
标Content-Encoding: gzip
头不再存在。此外,Transfer-Encoding
和Vary
也消失了,现在。
这里发生了什么?为什么这个新代码无法 gzip 文件?