tags:

views:

79

answers:

6

Let's say there is a page with 100 different user photo's shown on the page,
that is at least 100 DNS lookups right there, would this be reduced if I were to link using the an IP instead of a domain url?

http://217.345.33.444/images/photo.jpg instead of http://domain.com/images/photo.jpg

+4  A: 

It lowers DNS lookup overhead but will force painful, monotonous, error-prone changes if that IP ever changes down the road.

Also, once a single name is resolved, it shouldn't be looked-up again ...

andrewbadera
A: 

How confident are you that your IP address will never change? Also if you had those 100 images on 4 different domains performance would increase.

Andy Gaskell
+3  A: 

Its a bit late at night for my timezone, but I thought that DNS lookups are cached in various spots, (even on the local machine??) so it is not as bad as you think.

Thus the first call to lookup the domain will travel a fair way, but the results should be cached on in-between machines so that there is less performance hits with the later calls.

I am sure that this sort of thing was thought long and hard about by the designers of the DNS protocols.

Edit notes

Its taken me 3 edits just to get my spelling and grammar straight - it is definitely too late at night for me

Peter M
yes, also on the local machine
flybywire
+2  A: 

Why is that 100 DNS lookups? Are all the images on different domains? You should only typically incur one lookup per unique domain (and that's assuming that domain has never been resolved before).

Rex M
+2  A: 

DNS lookups are cached by your computer, so there will only be a single lookup per unique domain.

Additionally, most people use their internet provider's DNS server, and it will typically cache DNS lookups as well, so a lot of the time, the DNS lookup will just be a single network hop away.

You have no way of knowing when the IP address of a domain will change, so I do not recommend this approach.

Is there a reason you don't store the images on your own domain? If you did that:

  • the DNS issue would go away.
  • A lot of web servers don't allow hot linking of images, so this problem would be solved as well.
  • that would also create the possibility of spriting images together, if the set of images shown together doesn't change often.
Chi
good answer until you got to "Is there a reason you don't store the images on your own domain? If you did that:" I never said I don't host my own images =)
jasondavis
A: 

Every browser I know looks up for the DNS only once and than cache it. Even if it doesn't, the system does. There's no 100 lookups as you suspected.

You can take a proof of that with any simple traffic sniffer, as I did.

Havenard