三月 25th, 2007
建议打开WordPress的gzip压缩功能
Category: WordPress, Author: Nicky, Popularity: 10%
使用“Web Page Analyzer”做了一个测试,在关闭WordPress的gzip压缩功能和打开的情况下对比,压缩率高达70%,真是值得欣喜的一件事。从上面的数据上来看,只对text/html进行了压缩,我的CSS和JS代码还需要其他方法优化一下,gzip没有压缩它们。顺便发现FeedBurner烧制的Feed就采用了gzip压缩,而国内的Feedsky没有。
update: Dennys提示使用Apache的mod_deflate模块来压缩页面更爽,他还把这个和WordPress自带的gzip做了一个对比,多压缩了近100k的内容,因为WP自带的这个没有压缩js和css,直接配置mod_deflate模块就比较灵活了,可以自定义需要压缩的文件类型。
配置Apache2的mod_deflate模块压缩页面的方法:
修改httpd.conf或apache2.conf就不说了,主要说说修改.htaccess的方法(其实都差不多)。
1、首先确认你的虚拟主机启用了mod_deflate模块(我现在用的就没有)。
2、在.htaccess中加入:
<ifmodule mod_deflate.c>
AddOutputFilter DEFLATE html xml php js css
</ifmodule>
AddOutputFilter DEFLATE html xml php js css
</ifmodule>
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/xml application/x-httpd-php application/x-javascript text/css
</ifmodule>
AddOutputFilterByType DEFLATE text/html text/xml application/x-httpd-php application/x-javascript text/css
</ifmodule>
打开gzip压缩之后:
Real-Time Compression Check 检查结果:
Tags:gzip, WordPress.
评论数量(9) | Add Comments
本文网址:http://www.osxcn.com/wordpress/wordpress-compress-articles.html

