#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    162
    Rep Power
    62

    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.
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,126
    Rep Power
    4304
    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.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  4. #3
  5. Code Monkey V. 0.9
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2005
    Location
    A Land Down Under
    Posts
    2,110
    Rep Power
    1990
    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.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    162
    Rep Power
    62
    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.

IMN logo majestic logo threadwatch logo seochat tools logo