SlideShare a Scribd company logo
1 of 86
高性能网站最佳实践 ,[object Object]
课程 课程对象:所有感兴趣的人员 课程目的: 通过此课程,学员能熟悉高性能网站的优化原理, 14 条最佳优化实践的应用范围,熟悉工具的使用,并能网站类项目进行性能上的优化。
范围 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
前端优化的重要性
后端  vs.  前端 ,[object Object],95% 97% youtube.com 88% 95% yahoo.com 88% 80% wikipedia.org 86% 96% myspace.com 95% 97% msn.com 64% 86% google.com 92% 98% ebay.com 92% 81% cnn.com 86% 94% aol.com 86% 82% amazon.com Full Cache Empty Cache
性能黄金法则 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
HTTP 协议 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
HTTP 协议 ,[object Object],[object Object],[object Object],[object Object]
HTTP 协议 ,[object Object],[object Object],[object Object],[object Object]
80/20  性能法则 ,[object Object],[object Object],[object Object],[object Object]
Empty vs. Full Cache 1 用户请求  www.yahoo.com 2 用户请求其他页面 3 用户再次请求  www.yahoo.com
Empty vs. Full Cache with an empty cache 1 用户请求  www.yahoo.com 2 user requests other web pages 3 user re-requests www.yahoo.com
Empty vs. Full Cache 1 用户请求  www.yahoo.com 2 用户请求其他页面 3 用户再次请求  www.yahoo.com
Empty vs. Full Cache Expires header 3 用户再次请求  www.yahoo.com with a full cache 1 用户请求  www.yahoo.com 2 用户请求其他页面
Empty vs. Full Cache ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
浏览器 cache 实验
浏览器 cache 实验 ,[object Object],[object Object],[object Object]
浏览器 cache 实验 40-60%   ~20%   page views with empty cache users with empty cache
浏览器 cache 实验 ,[object Object],[object Object]
并行下载 两个组件 in parallel per hostname HTTP/1.1 GIF GIF GIF GIF GIF GIF
并行下载 ,[object Object],[object Object],[object Object]
最大化并行下载 响应时间  (seconds) 主机名
最大化并行下载 响应时间  (seconds) 规则:使用 2 个最多不超过 4 个的 主机名
总结 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
14 条最佳实践 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],来源于 Yahoo 研发团队在优化网络访问时积累下来的最佳实践
规则  1:  减少 Http 请求 ,[object Object],[object Object],[object Object],[object Object]
图片地图 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://www.w3.org/TR/html401/struct/objects.html#h-13.6
CSS Sprites –  推荐 ,[object Object],[object Object],http://alistapart.com/articles/sprites  <span style=&quot; background-image: url('sprites.gif'); background-position: -260px -90px;“ width:26px; height:24px;> </span>
内联图片 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],http://tools.ietf.org/html/rfc2397
合并脚本,合并样式表 3 7 youtube.com 1.5 6.5 Average 1 4 yahoo.com 1 3 wikipedia.org 2 2 myspace.com 1 9 msn.com 1 1 froogle.google.com 2 7 ebay.com 2 11 cnn.com 1 18 aol.com 1 3 amazon.com Stylesheets Scripts
合并脚本,合并样式表 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
规则 2: 使用 CDN ,[object Object],[object Object],[object Object],[object Object],[object Object]
规则 2: 使用 CDN ,[object Object]
规则 2: 使用 CDN ,[object Object],[object Object],[object Object],[object Object],[object Object]
规则 2: 使用 CDN ,[object Object]
规则 2: 使用 CDN ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
规则 2: 使用 CDN youtube.com Akamai yahoo.com wikipedia.org Akamai, Limelight myspace.com SAVVIS msn.com google.com Akamai, Mirror Image ebay.com cnn.com Akamai aol.com Akamai amazon.com
规则 2: 使用 CDN ,[object Object],[object Object],[object Object],[object Object],[object Object],CDN 通常按其带宽和流量收费
规则 3 :添加 Expires 头 ,[object Object],[object Object]
规则 3 :添加 Expires 头 ,[object Object],[object Object],[object Object]
规则 3 :添加 Expires 头 ,[object Object],[object Object],[object Object]
规则 3 :添加 Expires 头 ,[object Object],26 days 0% 0/7 0/3 0/32 youtube.com 100% 75% 0% 80% 4% 55% 1% 48% 0% % n/a 4/4 1/1 23/23 yahoo.com 1 day 2/3 1/1 6/8 wikipedia.org 1 day 0/2 0/2 0/18 myspace.com 34 days 3/9 1/1 32/35 msn.com 454 days 0/1 0/1 1/23 froogle.google.com 140 days 0/7 0/2 16/20 ebay.com 227 days 2/11 0/2 0/138 cnn.com 217 days 6/18 1/1 23/43 aol.com 114 days 0/3 0/1 0/62 amazon.com Median Age Scripts Stylesheets Images
规则 3 :添加 Expires 头 ,[object Object],修改所有页面中的页面组件的文件名; 文件名采用变量的方式; 文件命名可采用文件名 + 版本号的方式,如 yahoo_2.0.6.js ;
规则  4: 压缩组件 ,[object Object],[object Object]
Gzip vs. Deflate ,[object Object],[object Object],Deflate Gzip 67% 4.7K 73% 3.7K 14.1K Stylesheet 52% 0.5K 56% 0.4K 1.0K Stylesheet 58% 16.6K 64% 14.5K 39.7K Script 66% 1.1K 67% 1.1K 3.3K Script Savings Size Savings Size Size
Gzip:  并不仅仅适用  HTML ,[object Object],some some x youtube.com x x x yahoo.com x x x wikipedia.org x x x myspace.com deflate deflate x msn.com x x x froogle.google.com x ebay.com cnn.com some some x aol.com x amazon.com Stylesheets Scripts HTML
Gzip  配置  ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],适用于代理服务器
Gzip 边缘情形 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
规则 5: 将样式表放在顶部 ,[object Object],[object Object],[object Object],[object Object]
下载慢的感觉快
规则 6: 将脚本放在底部 ,[object Object],[object Object],[object Object],[object Object]
规则 6: 将脚本放在底部 ,[object Object],[object Object],[object Object]
规则 7: 避免 CSS 表达式 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
一次性的表达式 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
事件处理器 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
规则 8: 使用外部脚本和 CSS ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
加载后下载 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
动态内联 ,[object Object],[object Object],[object Object],[object Object],[object Object]
规则 9: 减少 DNS 查找 ,[object Object],[object Object],[object Object]
TTL (Time To Live) ,[object Object],[object Object],5 minutes www.youtube.com 1 minute www.yahoo.com 1 hour www.wikipedia.org 1 hour www.myspace.com 5 minutes www.msn.com 5 minutes www.google.com 1 hour www.ebay.com 10 minutes www.cnn.com 1 minute www.aol.com 1 minute www.amazon.com
浏览器  DNS 缓存 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
减少 DNS 查找 ,[object Object],[object Object]
规则 10: 精简 JavaScript ,[object Object],no yes no no yes yes yes no no no 精简外部脚本 ? no www.youtube.com yes www.yahoo.com no www.wikipedia.org no www.myspace.com yes www.msn.com yes froogle.google.com no www.ebay.com no www.cnn.com no www.aol.com no www.amazon.com 精简内联脚本 ?
精简   vs.  混淆 原始 JavaScript //this is a test javascript YAHOO.util.CustomEvent = function(type, oScope, silent, signature) { this.type = type; this.scope = oScope || window; this.silent = silent; this.signature = signature || YAHOO.util.CustomEvent.LIST; this.subscribers = []; if (!this.silent) { } var onsubscribeType = &quot;_YUICEOnSubscribe&quot;; if (type !== onsubscribeType) { this.subscribeEvent = new YAHOO.util.CustomEvent(onsubscribeType, this, true); } };
精简   vs.  混淆 精简后的 JavaScript YAHOO.util.CustomEvent=function(type,oScope,silent,signature){this.type=type;this. scope=oScope||window;this.silent=silent;this.signature=signature||YAHOO.util. CustomEvent.LIST;this.subscribers=[];if(!this.silent){} var onsubscribeType=&quot;_YUICEOnSubscribe&quot;;if(type!==onsubscribeType){this.subscribeEv ent=new YAHOO.util.CustomEvent(onsubscribeType,this,true);}};
精简   vs.  混淆 混淆后的 JavaScript YAHOO.util.CustomEvent=function (_1,_2,_3,_4){ this.type=_1; this.scope=_2||window; this.silent=_3; this.signature=_4||YAHOO.util.CustomEvent.LIST; this.subscribers=[]; if(!this.silent){ } var _5=&quot;_YUICEOnSubscribe&quot;; if(_1!==_5){ this.subscribeEvent=new YAHOO.util.CustomEvent(_5,this,true); } };
精简   vs.  混淆 ,[object Object],[object Object],[object Object],Dojo  节省 JSMin  节省 原始大小 21K (25%) 17K (21%) 85K Average 10K (29%) 8K (22%) 34K www.youtube.com 16K (38%) 14K (34%) 42K www.wikipedia.org 24K (28%) 23K (27%) 88K www.myspace.com 24K (25%) 19K (20%) 98K www.cnn.com 4K (10%) 4K (10%) 44K www.aol.com 48K (24%) 31K (15%) 204K www.amazon.com
精简   vs.  混淆 总结 ,[object Object],[object Object],[object Object],[object Object]
规则 11: 避免重定向 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
重定向 no yes – secondary page yes – secondary page yes – secondary page yes – initial page no yes – secondary page yes – initial page yes – secondary page no 重定向 www.youtube.com www.yahoo.com www.wikipedia.org www.myspace.com www.msn.com froogle.google.com www.ebay.com www.cnn.com www.aol.com www.amazon.com
避免重定向 ,[object Object],[object Object],[object Object],[object Object]
规则 12: 移除重复脚本 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
避免重复脚本 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
规则 13:  配置 ETag ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ETags 的问题 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
规则 14: 使 AJAX 可缓存 ,[object Object],[object Object],[object Object]
其它网站 YSlow 得分情况 前面删除了部分页面,一些公司的案例。 C(79) 豆瓣 D(66) 51.com F(31) 当当 F(40) MSN B(86) Yahoo F(36) 卓越亚马逊 A(91) 百度 A(93) Google D(64) 淘宝 F(26) 新浪 等级 网站
HttpWatch ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
Firebug ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
 
YSlow ,[object Object],[object Object],[object Object],[object Object],[object Object]
 
相关链接 ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
推荐图书
谢谢大家! ,[object Object]

More Related Content

What's hot

jiaju.com首页前端优化一期报告
jiaju.com首页前端优化一期报告jiaju.com首页前端优化一期报告
jiaju.com首页前端优化一期报告zhangsuoyong
 
從 Web Site 到 Web Application,從 Web Services 到 Mobile Services
從 Web Site 到 Web Application,從 Web Services 到 Mobile Services從 Web Site 到 Web Application,從 Web Services 到 Mobile Services
從 Web Site 到 Web Application,從 Web Services 到 Mobile ServicesKuo-Chun Su
 
Flash对象在(X)Html中的格式和参数及安全性
Flash对象在(X)Html中的格式和参数及安全性Flash对象在(X)Html中的格式和参数及安全性
Flash对象在(X)Html中的格式和参数及安全性taobao.com
 
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐twMVC
 
淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践jay li
 
Big Java, Big Data
Big Java, Big DataBig Java, Big Data
Big Java, Big DataKuo-Chun Su
 
如何使用 Xhprof 分析網站效能 (真實案例)
如何使用 Xhprof 分析網站效能 (真實案例)如何使用 Xhprof 分析網站效能 (真實案例)
如何使用 Xhprof 分析網站效能 (真實案例)Cyril Wang
 
如何使用 Xhprof 分析網站效能 (真實案例2)
如何使用 Xhprof 分析網站效能 (真實案例2)如何使用 Xhprof 分析網站效能 (真實案例2)
如何使用 Xhprof 分析網站效能 (真實案例2)Cyril Wang
 

What's hot (8)

jiaju.com首页前端优化一期报告
jiaju.com首页前端优化一期报告jiaju.com首页前端优化一期报告
jiaju.com首页前端优化一期报告
 
從 Web Site 到 Web Application,從 Web Services 到 Mobile Services
從 Web Site 到 Web Application,從 Web Services 到 Mobile Services從 Web Site 到 Web Application,從 Web Services 到 Mobile Services
從 Web Site 到 Web Application,從 Web Services 到 Mobile Services
 
Flash对象在(X)Html中的格式和参数及安全性
Flash对象在(X)Html中的格式和参数及安全性Flash对象在(X)Html中的格式和参数及安全性
Flash对象在(X)Html中的格式和参数及安全性
 
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
twMVC#26 | 淺談 ASP.NET Caching 技術與實踐
 
淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践
 
Big Java, Big Data
Big Java, Big DataBig Java, Big Data
Big Java, Big Data
 
如何使用 Xhprof 分析網站效能 (真實案例)
如何使用 Xhprof 分析網站效能 (真實案例)如何使用 Xhprof 分析網站效能 (真實案例)
如何使用 Xhprof 分析網站效能 (真實案例)
 
如何使用 Xhprof 分析網站效能 (真實案例2)
如何使用 Xhprof 分析網站效能 (真實案例2)如何使用 Xhprof 分析網站效能 (真實案例2)
如何使用 Xhprof 分析網站效能 (真實案例2)
 

Viewers also liked

透明计算与云计算
透明计算与云计算透明计算与云计算
透明计算与云计算longhao
 
Netputer
NetputerNetputer
Netputerlonghao
 
Vim get start_1.0
Vim get start_1.0Vim get start_1.0
Vim get start_1.0longhao
 
产品部内部交流平台
产品部内部交流平台产品部内部交流平台
产品部内部交流平台longhao
 
Dean Keynote Ladis2009
Dean Keynote Ladis2009Dean Keynote Ladis2009
Dean Keynote Ladis2009longhao
 
Node.js长连接开发实践
Node.js长连接开发实践Node.js长连接开发实践
Node.js长连接开发实践longhao
 
手机上的硬件设备及典型App
手机上的硬件设备及典型App手机上的硬件设备及典型App
手机上的硬件设备及典型Applonghao
 
软件重构
软件重构软件重构
软件重构longhao
 
借助社会化媒体的个人成长
借助社会化媒体的个人成长借助社会化媒体的个人成长
借助社会化媒体的个人成长longhao
 
Java并发编程培训
Java并发编程培训Java并发编程培训
Java并发编程培训longhao
 
并发编程实践
并发编程实践并发编程实践
并发编程实践longhao
 
无Ued产品的易用性讨论
无Ued产品的易用性讨论无Ued产品的易用性讨论
无Ued产品的易用性讨论longhao
 
Articulo Sindrome Nefrotico
Articulo Sindrome NefroticoArticulo Sindrome Nefrotico
Articulo Sindrome Nefroticoxelaleph
 
LeadMe 경험글 작성 가이드
LeadMe 경험글 작성 가이드LeadMe 경험글 작성 가이드
LeadMe 경험글 작성 가이드RAIZE
 
Everything is Marketing: Insights from the internship
Everything is Marketing: Insights from the internshipEverything is Marketing: Insights from the internship
Everything is Marketing: Insights from the internshipSameer Mathur
 

Viewers also liked (20)

透明计算与云计算
透明计算与云计算透明计算与云计算
透明计算与云计算
 
Netputer
NetputerNetputer
Netputer
 
Vim get start_1.0
Vim get start_1.0Vim get start_1.0
Vim get start_1.0
 
hadoop
hadoophadoop
hadoop
 
产品部内部交流平台
产品部内部交流平台产品部内部交流平台
产品部内部交流平台
 
Dean Keynote Ladis2009
Dean Keynote Ladis2009Dean Keynote Ladis2009
Dean Keynote Ladis2009
 
Node.js长连接开发实践
Node.js长连接开发实践Node.js长连接开发实践
Node.js长连接开发实践
 
手机上的硬件设备及典型App
手机上的硬件设备及典型App手机上的硬件设备及典型App
手机上的硬件设备及典型App
 
软件重构
软件重构软件重构
软件重构
 
借助社会化媒体的个人成长
借助社会化媒体的个人成长借助社会化媒体的个人成长
借助社会化媒体的个人成长
 
Java并发编程培训
Java并发编程培训Java并发编程培训
Java并发编程培训
 
并发编程实践
并发编程实践并发编程实践
并发编程实践
 
无Ued产品的易用性讨论
无Ued产品的易用性讨论无Ued产品的易用性讨论
无Ued产品的易用性讨论
 
RBG COM
RBG COMRBG COM
RBG COM
 
CV_CC_engl
CV_CC_englCV_CC_engl
CV_CC_engl
 
Articulo Sindrome Nefrotico
Articulo Sindrome NefroticoArticulo Sindrome Nefrotico
Articulo Sindrome Nefrotico
 
LeadMe 경험글 작성 가이드
LeadMe 경험글 작성 가이드LeadMe 경험글 작성 가이드
LeadMe 경험글 작성 가이드
 
Enciclopedia de los diferentes comandos de personalizacion de diapositivas p...
Enciclopedia  de los diferentes comandos de personalizacion de diapositivas p...Enciclopedia  de los diferentes comandos de personalizacion de diapositivas p...
Enciclopedia de los diferentes comandos de personalizacion de diapositivas p...
 
04 Aziende Comunicano
04   Aziende Comunicano04   Aziende Comunicano
04 Aziende Comunicano
 
Everything is Marketing: Insights from the internship
Everything is Marketing: Insights from the internshipEverything is Marketing: Insights from the internship
Everything is Marketing: Insights from the internship
 

Similar to 高性能网站最佳实践

[2008]网站重构 -who am i
[2008]网站重构 -who am i[2008]网站重构 -who am i
[2008]网站重构 -who am iTwinsen Liang
 
TBAD F2E 2010 review
TBAD F2E 2010 reviewTBAD F2E 2010 review
TBAD F2E 2010 reviewleneli
 
Web storage&web socket&canvas
Web storage&web socket&canvasWeb storage&web socket&canvas
Web storage&web socket&canvasmolice
 
Web dev road map part one
Web dev road map part oneWeb dev road map part one
Web dev road map part one安 闫
 
拆分初始化负载
拆分初始化负载拆分初始化负载
拆分初始化负载kaven yan
 
前端性能优化和自动化
前端性能优化和自动化前端性能优化和自动化
前端性能优化和自动化kaven yan
 
张所勇:前端开发工具推荐
张所勇:前端开发工具推荐张所勇:前端开发工具推荐
张所勇:前端开发工具推荐zhangsuoyong
 
高性能LAMP程序设计
高性能LAMP程序设计高性能LAMP程序设计
高性能LAMP程序设计fuchaoqun
 
非常靠谱 Html 5
非常靠谱 Html 5 非常靠谱 Html 5
非常靠谱 Html 5 Tony Deng
 
HTML5概览
HTML5概览HTML5概览
HTML5概览Adam Lu
 
OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发leneli
 
Exam 98-375 HTML5 Application Development Fundamentals
Exam 98-375 HTML5 Application Development FundamentalsExam 98-375 HTML5 Application Development Fundamentals
Exam 98-375 HTML5 Application Development FundamentalsChieh Lin
 
价值中国网站开发、管理经验探讨、分享、交流
价值中国网站开发、管理经验探讨、分享、交流价值中国网站开发、管理经验探讨、分享、交流
价值中国网站开发、管理经验探讨、分享、交流hizhubo
 
使用Big pipe提升浏览速度 wk_velocity
使用Big pipe提升浏览速度 wk_velocity使用Big pipe提升浏览速度 wk_velocity
使用Big pipe提升浏览速度 wk_velocitykumawu
 
缓存技术浅谈
缓存技术浅谈缓存技术浅谈
缓存技术浅谈Robbin Fan
 
2012 php conf slide PIXNET 如何使用 php
2012 php conf slide   PIXNET 如何使用 php2012 php conf slide   PIXNET 如何使用 php
2012 php conf slide PIXNET 如何使用 phpronnywang_tw
 
前端性能测试
前端性能测试前端性能测试
前端性能测试tbmallf2e
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)Wei Sun
 
淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践Du Yamin
 
浅析浏览器解析和渲染
浅析浏览器解析和渲染浅析浏览器解析和渲染
浅析浏览器解析和渲染Ailsa126
 

Similar to 高性能网站最佳实践 (20)

[2008]网站重构 -who am i
[2008]网站重构 -who am i[2008]网站重构 -who am i
[2008]网站重构 -who am i
 
TBAD F2E 2010 review
TBAD F2E 2010 reviewTBAD F2E 2010 review
TBAD F2E 2010 review
 
Web storage&web socket&canvas
Web storage&web socket&canvasWeb storage&web socket&canvas
Web storage&web socket&canvas
 
Web dev road map part one
Web dev road map part oneWeb dev road map part one
Web dev road map part one
 
拆分初始化负载
拆分初始化负载拆分初始化负载
拆分初始化负载
 
前端性能优化和自动化
前端性能优化和自动化前端性能优化和自动化
前端性能优化和自动化
 
张所勇:前端开发工具推荐
张所勇:前端开发工具推荐张所勇:前端开发工具推荐
张所勇:前端开发工具推荐
 
高性能LAMP程序设计
高性能LAMP程序设计高性能LAMP程序设计
高性能LAMP程序设计
 
非常靠谱 Html 5
非常靠谱 Html 5 非常靠谱 Html 5
非常靠谱 Html 5
 
HTML5概览
HTML5概览HTML5概览
HTML5概览
 
OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发OPOA in Action -- 使用MagixJS简化WebAPP开发
OPOA in Action -- 使用MagixJS简化WebAPP开发
 
Exam 98-375 HTML5 Application Development Fundamentals
Exam 98-375 HTML5 Application Development FundamentalsExam 98-375 HTML5 Application Development Fundamentals
Exam 98-375 HTML5 Application Development Fundamentals
 
价值中国网站开发、管理经验探讨、分享、交流
价值中国网站开发、管理经验探讨、分享、交流价值中国网站开发、管理经验探讨、分享、交流
价值中国网站开发、管理经验探讨、分享、交流
 
使用Big pipe提升浏览速度 wk_velocity
使用Big pipe提升浏览速度 wk_velocity使用Big pipe提升浏览速度 wk_velocity
使用Big pipe提升浏览速度 wk_velocity
 
缓存技术浅谈
缓存技术浅谈缓存技术浅谈
缓存技术浅谈
 
2012 php conf slide PIXNET 如何使用 php
2012 php conf slide   PIXNET 如何使用 php2012 php conf slide   PIXNET 如何使用 php
2012 php conf slide PIXNET 如何使用 php
 
前端性能测试
前端性能测试前端性能测试
前端性能测试
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)
 
淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践淘宝移动端Web开发最佳实践
淘宝移动端Web开发最佳实践
 
浅析浏览器解析和渲染
浅析浏览器解析和渲染浅析浏览器解析和渲染
浅析浏览器解析和渲染
 

高性能网站最佳实践

  • 1.
  • 2. 课程 课程对象:所有感兴趣的人员 课程目的: 通过此课程,学员能熟悉高性能网站的优化原理, 14 条最佳优化实践的应用范围,熟悉工具的使用,并能网站类项目进行性能上的优化。
  • 3.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11. Empty vs. Full Cache 1 用户请求 www.yahoo.com 2 用户请求其他页面 3 用户再次请求 www.yahoo.com
  • 12. Empty vs. Full Cache with an empty cache 1 用户请求 www.yahoo.com 2 user requests other web pages 3 user re-requests www.yahoo.com
  • 13. Empty vs. Full Cache 1 用户请求 www.yahoo.com 2 用户请求其他页面 3 用户再次请求 www.yahoo.com
  • 14. Empty vs. Full Cache Expires header 3 用户再次请求 www.yahoo.com with a full cache 1 用户请求 www.yahoo.com 2 用户请求其他页面
  • 15.
  • 17.
  • 18. 浏览器 cache 实验 40-60% ~20% page views with empty cache users with empty cache
  • 19.
  • 20. 并行下载 两个组件 in parallel per hostname HTTP/1.1 GIF GIF GIF GIF GIF GIF
  • 21.
  • 22. 最大化并行下载 响应时间 (seconds) 主机名
  • 23. 最大化并行下载 响应时间 (seconds) 规则:使用 2 个最多不超过 4 个的 主机名
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30. 合并脚本,合并样式表 3 7 youtube.com 1.5 6.5 Average 1 4 yahoo.com 1 3 wikipedia.org 2 2 myspace.com 1 9 msn.com 1 1 froogle.google.com 2 7 ebay.com 2 11 cnn.com 1 18 aol.com 1 3 amazon.com Stylesheets Scripts
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37. 规则 2: 使用 CDN youtube.com Akamai yahoo.com wikipedia.org Akamai, Limelight myspace.com SAVVIS msn.com google.com Akamai, Mirror Image ebay.com cnn.com Akamai aol.com Akamai amazon.com
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 61.
  • 62.
  • 63.
  • 64. 精简 vs. 混淆 原始 JavaScript //this is a test javascript YAHOO.util.CustomEvent = function(type, oScope, silent, signature) { this.type = type; this.scope = oScope || window; this.silent = silent; this.signature = signature || YAHOO.util.CustomEvent.LIST; this.subscribers = []; if (!this.silent) { } var onsubscribeType = &quot;_YUICEOnSubscribe&quot;; if (type !== onsubscribeType) { this.subscribeEvent = new YAHOO.util.CustomEvent(onsubscribeType, this, true); } };
  • 65. 精简 vs. 混淆 精简后的 JavaScript YAHOO.util.CustomEvent=function(type,oScope,silent,signature){this.type=type;this. scope=oScope||window;this.silent=silent;this.signature=signature||YAHOO.util. CustomEvent.LIST;this.subscribers=[];if(!this.silent){} var onsubscribeType=&quot;_YUICEOnSubscribe&quot;;if(type!==onsubscribeType){this.subscribeEv ent=new YAHOO.util.CustomEvent(onsubscribeType,this,true);}};
  • 66. 精简 vs. 混淆 混淆后的 JavaScript YAHOO.util.CustomEvent=function (_1,_2,_3,_4){ this.type=_1; this.scope=_2||window; this.silent=_3; this.signature=_4||YAHOO.util.CustomEvent.LIST; this.subscribers=[]; if(!this.silent){ } var _5=&quot;_YUICEOnSubscribe&quot;; if(_1!==_5){ this.subscribeEvent=new YAHOO.util.CustomEvent(_5,this,true); } };
  • 67.
  • 68.
  • 69.
  • 70. 重定向 no yes – secondary page yes – secondary page yes – secondary page yes – initial page no yes – secondary page yes – initial page yes – secondary page no 重定向 www.youtube.com www.yahoo.com www.wikipedia.org www.myspace.com www.msn.com froogle.google.com www.ebay.com www.cnn.com www.aol.com www.amazon.com
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77. 其它网站 YSlow 得分情况 前面删除了部分页面,一些公司的案例。 C(79) 豆瓣 D(66) 51.com F(31) 当当 F(40) MSN B(86) Yahoo F(36) 卓越亚马逊 A(91) 百度 A(93) Google D(64) 淘宝 F(26) 新浪 等级 网站
  • 78.
  • 79.
  • 80.
  • 81.  
  • 82.
  • 83.  
  • 84.
  • 86.