Newsflash

为了适应用户的使用,本站重新规划;由于时间上的关系,决定采用现成的CMS系统Joomla,同时根据我们的用户群体特点选用了常用的Joomla插件并进行优化。历时1个月的工作,今日正式上线。

 
powered_by.png, 1 kB

中文PHP arrow 开发技术 arrow 安装配置 arrow 使用mod_deflate提升网页浏览的速度
使用mod_deflate提升网页浏览的速度 输出PDF 打印 电子邮件
用户评分: / 0
好 
采编: Boban   
2007-11-22

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 < 电子邮件地址已被防垃圾邮件功能所隐藏, 您需要把Javascript功能打开才能看到。 > 写于2004年3月27日凌晨
附注:关于mod_deflate的详细内容,可以参考http://httpd.apache.org/docs-2.0/mod/mod_deflate.html

 
< 上一篇   下一篇 >
© 2000-2008 中文PHP网 版权所有 所有内容均由本站制作,未经许可,不得转载!
站长信箱:webmaster [at] 21php.com 沪ICP备05002508号
Joomla! is Free Software released under the GNU/GPL License.