apache通过mod_deflate打开gzip
作者:webfly 日期:2009-07-28
首先加载两个模块
LoadModule deflate_module modules/mod_deflate.so
LoadModule headers_module modules/mod_headers.so
在httpd.conf中加入
<Location />
# Insert filter
SetOutputFilter DEFLATE
# 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 \bMSIE !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
更详细地配置 见 http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
配置完毕打开 http://gzip.zzbaike.com/ 查看是否开启成功 压缩比例是多大
中华直销网首页打开gzip以后的压缩比例:
检测结果 |
|
| 是否压缩? | 是 |
| 压缩类型: | gzip |
| 源文件大小: | 100.24KB |
| 压缩后大小: | 20.94KB |
| 压缩率: | 79.1% |
上一篇
下一篇

文章来自:
Tags:
相关日志: