Reduce DNS Lookups

 reduce dns lookups

What is a DNS Lookup?

A DNS stands for Domain Name System which maintains records pertaining to which domain name maps to which IP address. This is commonly compared to a phonebook in that people’s names are associated to a particular phone number. More specifically, a DNS lookup is the process of finding which IP the domain name belongs to. This system allows us to use user-friendly domains such as while still being able to communicate with the server that stores the requested information.

The process of performing the DNS lookup falls on the responsibility of the browser. Upon accessing a web page, the browser finds all resources which require a DNS lookup and must wait until the lookup completes before it can download anything. According to YSlow, DNS lookups on average take between 20-120ms to complete.

This article will cover how to reduce DNS lookups in order to help improve overall page load times.

DNS Lookup Example

To demonstrate an example of how DNS lookup time can impact webpage speed we’ll run a test of through web page test.


In total, 32 requests are made and of these, 7 requests required a DNS lookup. In total, the DNS lookup time for these resources took 1.23 seconds. As we can see, the time required to complete a DNS lookup can add up fast which is why is it important to know how to reduce DNS lookups to help improve page speed performance.

How To Reduce DNS Lookups

To process of reducing DNS lookups is quite straightforward and can be achieve by adopting either or both of the following suggestions.

  • Simply reduce the amount of hostnames that are requested in order to generate your web page. For example, if you are making external requests to generate social icon buttons, fonts, libraries, etc. these all require a DNS lookup. Determine if all of these external resources are in fact necessary and evaluate the cost/benefit ratio between keeping the external resources and the additional loading time that this creates.
  • Download the files that are being referenced to an external resource and host them on your origin server or a CDN. This way, these resources will be retrieved without having to make an additional DNS lookup. Storing them on a CDN will help further improve loading times as users will be delivered content from the closest edge server. Additionally, hosting files on a CDN will help take a load off of the origin server.

Improve Speed of Remaining DNS Lookups

To reduce DNS lookups by following the suggestions above is a good step towards optimizing the amount of lookups required. However, what about optimizing the DNS lookups that are necessary to render the site. There are a number of ways to improve these as well, including:

  • Increase your DNS records’ TTL to ensure they stay cached longer
  • Implement DNS Prefetching to allow the browser to perform DNS lookups in the background
  • Minimize the amount of CNAME records
  • Defer parsing of JavaScript so that your above-the-fold content is loaded first.

Thanks to DNS caching, the browser is not required to perform a lookup each time it makes a request from the host as the results can be cached. If a higher TTL is set, this will decrease the likelihood that the browser will need to perform another DNS lookup for the same host at a later time. Additionally, deferring the parsing of JavaScript will allow for the important content to first be loaded and then load the non-critical JS. This method will not inherently improve your DNS lookup times, however will optimize them so that users are not waiting on a lookup to complete for a resource which isn’t required to display the page.

If you receive a recommendation from Google Pagespeed or Gtmetrix to reduce DNS lookups, use the above suggestions to help satisfy this recommendation and further improve your site’s performance.

Leave A Comment?