Apache2.x中设置gzip

在Apache2.x中使用mod_deflate进行gzip压缩,配置信息如下:

LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so

# gzip 设置
# Only compress specified content type
# see also http://www.devside.net/guides/config/compression

# The value must between 1 (less compression) and 9 (more compression)
DeflateCompressionLevel 7
# compress content with type html, text, and css
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php application/json
# place filter 'DEFLATE' on all outgoing content
SetOutputFilter DEFLATE
# Properly handle old browsers that do not support compression
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

参考资料:
apache 2.2.15中配置mod_deflate
httpd.conf -- compression

发表评论

电子邮件地址不会被公开。 必填项已用*标注