博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Best Practices for Speeding Up Your Web Site(一)

Posted on 2012-04-15 23:14  乌雲安全  阅读(226)  评论(0编辑  收藏  举报

雅虎通过研究实践,总结出加快网站速度最好的方法,总共35条,分为7类。分别是:Content、Server、Cookie、CSS、JavaScript、Images、Mobile 。

一、content(内容)

   1、Make Fewer HTTP Requests:减少http请求次数。网站加载慢主要是HTTP请求次数过多。

       (1)Combined files:合并css、javascript文件,将css、javascript放分别放到一个文件中。

       (2)CSS Sprites:将网站中的图片合并到一张图片中,通过background-image、background-position属性,一方面较少http请求,一方面合并后会较少图片大小。

        (3) Images maps:主要用于相邻图片。目前的浏览器不支持。

   2、Reduce DNS Lookups:减少DNS查询。域名到IP的转换过程中,请求的页面并没有加载,只有转换后才会开始加载。浏览器会缓存,IE缓存时间是30分钟,火狐缓存时间是1分钟。

   3、Avoid Redirects:避免重定向。重定向状态码是301、302。

   4、Make Ajax Cacheable:将Ajax缓存。

   5、Postload Components:后加载的内容。

   6、Preload Components:与前一条相反。

   7、Reduce the Number of DOM Elements

   8、Split Components Across Domains

   9、Minimize Number of iframes

  10、Avoid 404s