优化以减少网站加载时间 [英] Optimizations to reduce website loading time
问题描述
可以对网站进行一些重要的优化以减少加载时间?
删除/最小化任何瓶颈在服务器端。为此,使用类似Xdebug或Zend Debugger的分析器来确定应用程序在执行昂贵和缓慢操作的位置。尽可能实现缓存。使用OpCode缓存。如果这还不够快,可以考虑投资更多的CPU或RAM或SSD(取决于您是CPU,IO还是内存绑定)
对于一般服务器/客户端侧面优化,请参阅Yahoo YSlow!用户指南。
它基本上总计为:
- 最小化HTTP请求
- 使用内容传送网络
- 添加到期或高速缓存控制标题
- 将StyleSheets放在顶部
- 将脚本放在底部
- 避免使用CSS表达式
- 使JavaScript和CSS外部化
- 减少DNS查询
- 避免重定向
- 删除重复脚本
- 配置ETags
- Make AJAX Cacheable
- 对AJAX请求使用GET
- 减少DOM元素数量
- 否404s
- 减少Cookie大小
- 将无Cookie网域用于组件
- 不要在HTML中缩放图片
- 使favicon.ico小巧且可缓存
同时查看下面提供的评论,因为它们为其他用户提供了一些额外的有用信息。
What are some important optimizations that can be made to a website to reduce the loading time?
Remove/Minimize any bottlenecks on the server side. For this purpose, use a profiler like Xdebug or Zend Debugger to find out where your application is doing expensive and slow operations. Implement caching where possible. Use an OpCode Cache. If this still isn't fast enough consider investing in more CPU or RAM or SSDs (depending on whether you are CPU, IO or Memory bound)
For general server/client side optimizations, see the Yahoo YSlow! User Guide.
It basically sums it up to:
- Minimize HTTP Requests
- Use a Content Delivery Network
- Add an Expires or a Cache-Control Header
- Gzip Components
- Put StyleSheets at the Top
- Put Scripts at the Bottom
- Avoid CSS Expressions
- Make JavaScript and CSS External
- Reduce DNS Lookups
- Minify JavaScript and CSS
- Avoid Redirects
- Remove Duplicate Scripts
- Configure ETags
- Make AJAX Cacheable
- Use GET for AJAX Requests
- Reduce the Number of DOM Elements
- No 404s
- Reduce Cookie Size
- Use Cookie-Free Domains for Components
- Avoid Filters
- Do Not Scale Images in HTML
- Make favicon.ico Small and Cacheable
Also see the comments contributed below, as they contain some additional useful information for other users.
这篇关于优化以减少网站加载时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!