October 16th, 2011, 05:18 PM
What does an HTTP request actually cost?
Hey guys. I tried searching for this, but I can't find an actual value that can be used for a comparison. In general terms, what is a rough estimate on the delay caused by each HTTP request? We'll say the server and client are within 1000 miles, with a 15 hop maximum. I'm trying to decide if it would be better to combine every image on a website into one large sprite, or just use the multiple sprites I'm using. The issue with one large sprite is that image A is ~950px wide, but image B is lets say ~600px wide. If I can't fill that extra 350px, that seems like an unnecessary overhead. However, if it's still less expensive than a round trip HTTP request, it might be worth it.
October 16th, 2011, 08:01 PM
There are a lot of variables here. One of which is how many cookies are set on the domain. Another is the difference in file-size between the 1 vs. 2 images.
I, for one, prefer not to use a single sprite for all of the interface/design images like Yahoo does. It's easier to create and maintain multiple sprite images than a single huge one.
The distance between the client and the server does affect things, but that's not something you can generally control. If you are worried about it, then you should use a CDN to serve your static content.
October 16th, 2011, 08:02 PM
If you want to check things like this, I'd suggest using FireBug to check the loading times of both variants of the pages. That way you'll be able to see which loads and renders faster. Under "normal" circumstances, a single larger sprite image will load faster because there's only the overheads for one request, but this does also depend on the size of the files that you are using.
October 16th, 2011, 08:42 PM
Kravvitz, until you said something, I thought CDNs were out of my price range, but amazon is actually well priced. I'll definitely consider this.
Catacaustic - My servers are on my local network, so this would be a biased test. I suppose I could mock up two different versions and run over to a buddies house later this week for a crude test though.
Thanks for the input, I'll figure out a good testing method and see what I can do.