4chan 前端頁面的調校... (cookie-free domain 的重要性)

Chris Poole (4chan 的創辦人) 寫了一篇「Small things add up」,說明針對前端頁面的調整帶來的效能改善...

YSlowPageSpeed 都反應靜態內容 (像是圖片) 是從帶有 cookie 的 domain (4chan.org) 提供服務。

所以 Chris Poole 打算把靜態內容換到一個新的網域下。

首先是選擇新的 cookie-free domain 名稱,由於不需要好記 (因為是程式在用),所以在選擇時愈短愈好,這可以讓 html 內的大小會少一些 (即使是 gzip 後還是有差),所以 Chris Poole 選擇了 4cdn.org

而更大的改善其實是在 cookie 這塊。4chan 平均的 cookie 大小大約是 1KB,這表示每一個到 4chan.org 的 request 都要送出 1KB 的 cookie 資訊。對於行動用戶來說,上傳的頻寬就這樣被浪費掉了,在搬移到新的 4cdn.org 後可以省下大量的上傳頻寬:

By migrating to the new domain, end users now save roughly 100 KB upstream per page load, which at 500 million pageviews per month adds up to 46 terabytes per month in savings for our users. I find this unreal.

Leave a Reply

Your email address will not be published. Required fields are marked *