Originally seen at: https://varvy.com/pagespeed/dns-lookups.html
Varvy is now Down and this Content is for Archive Purposes.

Minimize DNS lookups

What are DNS lookups?

  • DNS stands for “Domain name system”
  • Domain names like “example.com” must be mapped to an ip address to be found
  • The DNS lookup is a request to another server requesting the ip address for a certain domain name

dns lookup

For any resource to be downloaded for your page, the browser must “look it up”. The browser must do this at least once for each domain your webpage is receiving resources from.

As a webpage becomes more feature-rich it often uses more DNS lookups which makes it render much slower.

This process can slow down your webpage considerably and one of the decisions you will need to make about your pagespeed is how many DNS lookups are too much.

waiting for multiple dns lookups

A very small webpage that should load in one second, can take additional seconds to download, simply because of additional DNS lookups. If you are experiencing slow page loads, see how many DNS lookups your webpage requires and decide why you are using whatever you are. The amount of time added to your pagespeed time for every third party resource is known as the DNS lookup time.

One example of this might be a social button (facebook / twitter/ google +) these social buttons may request one or more other resources that you don’t really think about which can add even more DNS lookups. Many features of a modern webpage are resource heavy and call different domains to do their job. Another example of this is Google webfonts. They actually require two DNS lookups.

To get a good idea of what your webpage is asking for overall is one of the first steps in creating a faster more enjoyable page for your users. A great starting point is the page speed tool which tells you how many requests your webpage is making.

Know what your webpage is doing. Decide what is important to your page.

Is a webfont worth an extra second or two? Sometimes yes, sometimes no. Are social buttons more important than pagespeed? Depends on the person.

Creating a good balance between pagespeed and DNS lookups is mostly a matter of deciding what is important for your webpage.

How to find out what DNS lookups are happening on your page

The first step is to know what your page is requesting (the resources need to load page). See how many requests your page is loading with our resource check tool. Each different domain that is needed to load those resources will require at least one dns lookup.

Example: If you are using a javascript from twitter for a twitter button, then a dns lookup will occur for the domain name twitter.com and if you are also using one for facebook, well then that is another domain and will require a dns lookup as well.

Go to Webpagetest.org and test your page there. It will display how many requests your webpage is making. Look carefully at the results and count the DNS lookups.

How to improve dns lookups for faster page speed

Speed can be improved by removing or deferring dns calls.

Even if you can not remove the things that are making the dns calls, you can still improve the speed of your page by not loading them initially.

This is often accomplished by deferring the javascript that is not needed for the initially visible above the fold content of your page.

To learn more about loading only above the fold content first, consider learning about the critical rendering path.

Leave a Comment