Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Using a CDN can vastly improve the load time of a website. I been thinking of using it to host all my external files like CSS, JS, Images, Videos etc. However I was thinking when linking to a CDN, wouldn't the browser have to use additional DNS lookup? So wouldn't this be counter productive? Or is the benefit to host every external files on a CDN out weighs the additional cost of a DNS lookup?

What are your thoughts?

share|improve this question
add comment

3 Answers 3

You could try both and use a service like http://www.webpagetest.org to see which option works best.

share|improve this answer
    
+1, great site. –  Marco Demaio Apr 3 '12 at 19:36
add comment

Yes, a DNS lookup will have to take place, however, as with most things these days; they have the possibility of being cached either by the OS, or by the browser itself.

You'll find that servers used for DNS resolution are normally much closer both topologically and geographically to the user than your server; meaning a smaller round-trip time than normal (DNS servers are normally located within the network of a user's ISP). A DNS lookup is also much smaller than the downloading of a web resource.

With this in mind, it'd be unlikely for such a small hit to outweigh such a potentially large gain (the fast download of all your assets). All in all, you should find that using a CDN will give you an advantage.

share|improve this answer
add comment

Actually the DNS lookup will be only ONE!

Once the OS looked up the domain DNS it will store the IP of the domain in its internal DNS table, and call directly the IP for all subsequent requests.

On Windows you can view the DNS table running the command: ipconfig /displaydns

Basically if in your site thare are 100 images + js + css and they are all on a CDN at some-cdn-domain.com, the browser will do only 1 DNS lookup, and not 100.

Therefor 1 DNS lookup will always be a no issue in term of speed. It could be if on the CDN you had only one file, but I struggle to see how a website can have only one static file nowadays.

share|improve this answer
    
Agreed, but in many cases, webmasters will create an alias to the CDN, which leads to 2 DNS resolve points. –  Ferdy Apr 4 '12 at 9:36
    
@Ferdy: alias on CDNs aren't usually just a different paths?! But different paths on the same CDN domain, therefor the DNS lookup should be only one, one per domain and NOT one per path. –  Marco Demaio Apr 4 '12 at 21:34
    
What is mean is this, often webmasters will create a clean alias in their own domain: static.yourdomain to com which will point to subdomain.cdn.com. That's two DNS points. –  Ferdy Apr 5 '12 at 6:52
    
@Ferdy: well if you create a subdomain you will definitely have 1 more DNS lookup, but still you will have a total of 2 DNS lookups (one the main domain and one for the subdomain), and not 100 DNS lookups (one for each image) unless you think to create a subdomain for each image on your web site. In such a case I would be worried it could be called overoptimization. –  Marco Demaio Apr 5 '12 at 20:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.