為了加強web server效能,研究了一下,
memo幾個方便可行的重點:
1) Minimize HTTP Requests
減少css , js , images 檔案數
2) Add an Expires or a Cache-Control Header
html header 中加上 expire time
3) Put Stylesheets at the Top
將include css放到頁面頂端
4) Put Scripts at the Bottom
將include js放到頁面底端
5) Avoid CSS Expressions
不要使用css中的expression的功能
6) Make JavaScript and CSS External
盡量把css & js放進外部檔案再include, 減少頁面中使用script & style tag的情況
7) Reduce DNS Lookups
盡量別使用 https://epc.devicevm.com.tw/images/a.jpg 這種網址,改用 /images/a.jpg 代替。
8) Minify JavaScript and CSS
css & js 放上EPC前,可先minify一下,有個網頁版的 http://dean.edwards.name/packer/
9) Avoid Redirects
減少redirect網頁的次數
10) Remove Duplicate Scripts
減少重複include js & css,尤其是jquery的plugin部份特別容易發生
11) Flush the Buffer Early
在head之後加上flush的php code
12) Use GET for AJAX Requests
傳送少量資料使用GET method
13) No 404s
減少找不到檔案的404 request發生
14) Don’t Scale Images in HTML
images應該製作成剛好需要的大小,且img tag需指定width & height
—
Reference urls:
Best Practices for Speeding Up Your Web Site
http://developer.yahoo.com/performance/rules.html
《高性能网站建设指南》读后随感
http://www.dbanotes.net/web/high_performance_web_site.html