ITeye博客

Apache2.x中设置gzip

JetMah · 2010-12-01 13:26 · Web&Server · Web前端 · Markdown

原文出处: Apache2.x中设置gzip
作者: Jet Mah from Java堂
声明: 可以非商业性任意转载, 转载时请务必以超链接形式标明文章原始出处、作者信息及此声明!

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

 

  1. LoadModule deflate_module modules/mod_deflate.so
  2. LoadModule headers_module modules/mod_headers.so
  3. # gzip 设置
  4. # Only compress specified content type
  5. # see also http://www.devside.net/guides/config/compression
  6. <IfModule mod_deflate.c>
  7. # The value must between 1 (less compression) and 9 (more compression)
  8. DeflateCompressionLevel 7
  9. # compress content with type html, text, and css
  10. AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php application/json
  11. # place filter 'DEFLATE' on all outgoing content
  12. SetOutputFilter DEFLATE
  13. # Properly handle old browsers that do not support compression
  14. BrowserMatch ^Mozilla/4 gzip-only-text/html
  15. BrowserMatch ^Mozilla/4\.0[678] no-gzip
  16. BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
  17. </IfModule>

 

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

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。