主题:Google开发网页的新工具Page Speed -- meokey
Google今天公布了一个网页开发工具,Chrome的网页开发插件Page Speed。这个工具可以帮助网站开发者分析优化网站性能。我试着分析了一下ccthere.com,Page Speed给出了以下的分析,希望对铁手有所帮助。
www.ccthere.com首页
结果相当不错,唯一的优化建议是使用压缩
Compressing the following resources with gzip could reduce their transfer size by 84.1KiB (71% reduction).
Compressing http://www.ccthere.com/boards/ could save 44.3KiB (78% reduction).
Compressing http://www.ccthere.com/incs/rs.php?T=2&V=1 could save 26.9KiB (67% reduction).
Compressing http://pagead2.googlesyndication.com/pagead/show_ads.js could save 7.5KiB (59% reduction).
Compressing http://www.ccthere.com/incs/rs.php?T=0&V=1 could save 3.6KiB (67% reduction).
Compressing http://www.ccthere.com/intr/indexfun.php?DZ=3&T=3&RID=1&SID=0&SA=0&PIDRT=0&Rnd=1301497334999 could save 1.8KiB (59% reduction).
一网打尽
有3个建议:
1. Combine images into CSS sprite
The following images served from ccthere.com should be combined into as few images as possible using CSS sprites.
http://www.ccthere.com/bbsIMG/bf/face1.gif
http://www.ccthere.com/bbsIMG/bf/face5.gif
http://www.ccthere.com/bbsIMG/bf/face6.gif
http://www.ccthere.com/bbsIMG/bf/face7.gif
http://www.ccthere.com/bbsIMG/bf/face9.gif
http://www.ccthere.com/bbsIMG/egg.gif
http://www.ccthere.com/bbsIMG/flower.gif
http://www.ccthere.com/bbsIMG/intop.gif
http://www.ccthere.com/bbsIMG/np.gif
http://www.ccthere.com/bbsIMG/np1.gif
http://www.ccthere.com/bbsIMG/qt.gif
http://www.ccthere.com/bbsIMG/tj.gif
http://www.ccthere.com/bbsIMG/xml.gif
http://www.ccthere.com/incs/help.gif
http://www.ccthere.com/incs/pgn.gif
2. Enable compression
Compressing the following resources with gzip could reduce their transfer size by 91.1KiB (73% reduction).
Compressing http://www.ccthere.com/board/%E4%B8%80%E7%BD%91%E6%89%93%E5%B0%BD/ could save 53.1KiB (80% reduction).
Compressing http://www.ccthere.com/incs/rs.php?T=2&V=1 could save 26.9KiB (67% reduction).
Compressing http://pagead2.googlesyndication.com/pagead/show_ads.js could save 7.5KiB (59% reduction).
Compressing http://www.ccthere.com/incs/rs.php?T=0&V=1 could save 3.6KiB (67% reduction).
The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:
http://www.ccthere.com/bbsIMG/bf/face1.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/bf/face5.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/bf/face6.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/bf/face7.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/bf/face9.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/egg.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/flower.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/intop.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/load.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/np.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/np1.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/qt.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/tj.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/weblogo.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/xml.gif (expiration not specified)
http://www.ccthere.com/incs/help.gif (expiration not specified)
http://www.ccthere.com/incs/pgn.gif (expiration not specified)
http://pagead2.googlesyndication.com/pagead/show_ads.js (1 hour)
http://cache.yoono.com/static/sb/share/green-30.png (4 days 11 hours)
然后,随便树展了一个帖子:
同样,也是给出了以上三个建议
1. Enable compression
Compressing the following resources with gzip could reduce their transfer size by 75.4KiB (72% reduction).
Compressing http://www.ccthere.com/incs/rs.php?T=2&V=1 could save 26.9KiB (67% reduction).
Compressing http://www.ccthere.com/alist/2328783 could save 25.2KiB (80% reduction).
Compressing http://www.ccthere.com/article/2328783.html could save 19.6KiB (72% reduction).
Compressing http://www.ccthere.com/incs/rs.php?T=0&V=1 could save 3.6KiB (67% reduction).
2. Combine images into CSS sprites
The following images served from ccthere.com should be combined into as few images as possible using CSS sprites.
http://www.ccthere.com/bbsIMG/bf/face1.gif
http://www.ccthere.com/bbsIMG/egg.gif
http://www.ccthere.com/bbsIMG/flower.gif
http://www.ccthere.com/bbsIMG/np.gif
http://www.ccthere.com/bbsIMG/np1.gif
http://www.ccthere.com/incs/pgn.gif
3. Leverage browser caching
The following cacheable resources have a short freshness lifetime. Specify an expiration at least one week in the future for the following resources:
http://www.ccthere.com/bbsIMG/bf/face1.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/egg.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/flower.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/load.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/np.gif (expiration not specified)
http://www.ccthere.com/bbsIMG/np1.gif (expiration not specified)
http://www.ccthere.com/incs/pgn.gif (expiration not specified)
http://cache.yoono.com/static/sb/share/green-30.png (4 days 11 hours)
我也去试了试。方便,直观。给出的建议也很有用。强烈推荐给速度控的站长们。
不过它的那个压缩推荐可能在判断上出了问题。有的网站明明已经启用了压缩,但没有被检测出来。估计是它只认gzip这一种压缩方式?
在apache上安装好之后,无需任何配置,就可以对网页进行加速了,主要是控制图形和css/js的expires,和css的压缩等,效率很高,本来很多需要写在htaccess里控制http header的优化方法,这下都不要了,google帮您搞掂。缺点是只支持apache,lighttpd就不能用罗~
在这里可以找到 http://developer.yahoo.com/yui/compressor/ 用来压缩 javascript 和 css。google 那里也能找到 closure compiler http://code.google.com/closure/compiler/
比较了一下,发现那个 closure compiler似乎有bug。具体表现在 ajax 函数里面的由 XMLHttpRequest 返回的变量名也被改变,导致ajax调用返回时似乎有问题。yahoo 那个就没这个问题。
图片的 expiration 怎么显式设定呢?
比如:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType text/html "access plus 2 days"
ExpiresByType image/gif "access plus 60 days"
ExpiresByType image/jpg "access plus 60 days"
ExpiresByType image/png "access plus 60 days"
ExpiresByType application/x-javascript "access plus 60 days"
ExpiresByType text/css "access plus 60 days"
ExpiresByType image/x-icon "access plus 360 days"
</IfModule>链接