Posts Tagged ‘http’

Reduce # of HTTP requests

Saturday, November 1st, 2008

I think I’ve become more absent-minded recently. Several days ago I received an Amazon package at home. I left it lying around and unopened until this morning. I remembered that I ordered a book that I’ve coveted for several months and that the book is in that package. Lol.

So I spent this morning reading Rule 1 fromĀ High Performance Web Sites (that’s the book that I received in the package). It’s interesting really, the design of this website tries to follow that rule pretty closely. That is, it tries to reduce the number of HTTP requests being sent to the server. HTTP requests add a burden to the server and to your web browsers. It gets slower; much slower. Of course Firefox users would be very familiar with tabs auto-restoring during crashes/restarts. At the point of auto-restoring, it is not uncommon for me to load 50 tabs at the same time. If each site has 20 HTTP requests in average (Blimey! That many? You’ll be surprised, some website have over a hundred requests; heck, even my faculty website has over 40 HTTP requests.), the auto-restore can easily amassed 1000 requests. Firefox, by default, limits concurrent HTTP requests to about 30 (check out your about:config, search for network.http.max-connections). Older Firefox default to 2 concurrent connection per server. Ouch!

I’m hoping that this blog will not become a beast in term of HTTP requests. The initial design (from default Wordpress 2.6.3) contains over 10 requests. I’ve redesigned the page substantially and reduces the amount of requests by quite a bit. Even after adding line-numbering (a vertical image strip) and Google Analytics (a whopping 2 requests, 1 for the javascript file, another for the actual tracking, which uses a heavily parameterized GET request for a 1×1 gif image), this site has a manageable 6 requests. I plan to add a Javascript library for some of the additional stuffs I plan to do. But I’ll try to do that while reducing other requests. My first project is to replace that image for line numbers with a Javascript. So the Javascript library will take the place of the image download.

My next game will involve playing around with the cache settings, probably even installing the notoriously problematic plugin, WP Super Cache.

Readers who are planning to create a website of their own may also want to consider sticking with HTML standards instead of XHTML standards. That will save you tonnes of closing tags. The w3cschool HTML tag reference pages will indicate whether the closing tag is optional for HTML. I have no intention to switch to HTML for this blog though. As long as I don’t get digged or slashdotted, I don’t expect amazingly high amount of traffic… Heck, even 100 readers a day will be pretty amazing! Saving bandwidth is not my concern right now.

Anyway, for more of interesting stuffs and analysis on how to make your frontend better, be it website or webapps, try reading Steve Souders’ website.