| 首页 | 新闻 | 网页 | 设计 | 色彩 | 原创 | 视觉 | 素材 | 动漫 | 酷站 | 策划 | 文案 | 访谈 | 运营 | 编程 | 数据库 | 服务器 | 下载 | 图库 | 
您的位置: 幽幽天空 > 网页 > 服务器 > Apache教程 > 文章正文 用户登录
google使用技巧
我的餐馆点评网站
Flash Remoting -
用Flash MX制作MO
MOMO源码
像素字体使用技巧
ViewletBuilder 4
利用mx2004打造像
flashremoting实践
使用report build

使用mod_deflate提升网页浏览的速度           

使用mod_deflate提升网页浏览的速度

作者:佚名 来源:中文PHP网 作者: Boban 更新:2006-8-25 21:05:35 错误报告 我要投稿

apache1.3.x可以用mod_gzip进行优化网页浏览的速度,可以明显的感觉到速度的提升。在apache2中也尝试用mod_gzip,但是配置后确发现网页不能正确显示(空白页),所以改换mod_deflate。

在Linux命令行下运行以下命令安装mod_deflate模块(斜体是apache2的目录)

/usr/local/apache2/bin/apxs -i -c /root/httpd-2.0.48/modules/filters/mod_deflate.c

编辑httpd.conf,加入以下内容:

LoadModule deflate_module modules/mod_deflate.so

DeflateFilterNote ratio
LogFormat '"%v %h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" (%{ratio}n)' deflate

<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 MSIE !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命令不对?注释这一行
# Header append Vary User-Agent env=!dont-vary
</Location>

#查找Customlog 注释原来的的一行,改成
CustomLog logs/deflate_log deflate

#查看logs目录下deflate_log文件,你可以看到许多这样的信息:
"www.21php.com 220.163.107.88 - - [27/Mar/2004:01:03:55 -0800] "GET /ad/usrlogo
/21PHPLOGO_88X31.gif HTTP/1.1" 200 3656 "http://soft.ttee.com/vbb/" "Mozilla
/4.0 (compatible; MSIE 5.5; Windows 98)"" (-)
"www.21php.com 211.144.88.138 - - [27/Mar/2004:01:03:57 -0800] "GET /tutorial/t
utorial.php?tid=68 HTTP/1.1" 200 5173 "http://www.21php.com/tutorial/tutorial.
php?catalogid=12" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MyIE2; .
NET CLR 1.0.3705; Alexa Toolbar)"" (29)
"www.21php.com 211.144.88.138 - - [27/Mar/2004:01:03:58 -0800] "GET /style.css
HTTP/1.1" 304 - "http://www.21php.com/tutorial/tutorial.php?tid=68" "Mozilla
/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MyIE2; .NET CLR 1.0.3705; Alexa Tool
bar)"" (-)
"www.21php.com 211.144.88.138 - - [27/Mar/2004:01:03:58 -0800] "GET /images/bar
-4.gif HTTP/1.1" 304 - "http://www.21php.com/tutorial/tutorial.php?tid=68" "
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MyIE2; .NET CLR 1.0.3705; Ale
xa Toolbar)"" (-)
"www.21php.com 211.144.88.138 - - [27/Mar/2004:01:03:58 -0800] "GET /images/log
o.gif HTTP/1.1" 304 - "http://www.21php.com/tutorial/tutorial.php?tid=68" "M
ozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MyIE2; .NET CLR 1.0.3705; Alex
a Toolbar)"" (-)
"www.21php.com 211.144.88.138 - - [27/Mar/2004:01:03:58 -0800] "GET /images/ico
n1.gif HTTP/1.1" 304 - "http://www.21php.com/tutorial/tutorial.php?tid=68" "
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MyIE2; .NET CLR 1.0.3705; Ale
xa Toolbar)"" (-)

Boban <boban@21php.com > 写于2004年3月27日凌晨
附注:关于mod_deflate的详细内容,可以参考http://httpd.apache.org/docs-2.0/mod/mod_deflate.html

文章录入:skyuu    责任编辑:skyuu 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    发表评论:
    姓名:  评 分: 1分 2分 3分 4分 5分
     
  • 严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
  • 用户需对自己在使用幽幽天空服务过程中的行为承担法律责任。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表机友个人观点,与本网站立场无关。