How to Reduce DNS Lookups

March 2, 2023


DNS lookup is an essential component of internet communication as it provides means to translate human-readable domains into machine-readable IP addresses. However, excessive DNS lookups can impact website performance significantly.

This article explains the importance of reducing DNS lookups and provides ten tips to optimize DNS lookups on your website.

How to reduce DNS lookups.

What Is DNS Lookup?

DNS lookup is the process of querying a DNS server, during which the server translates a domain name into the corresponding IP address. Web browsers request DNS lookups every time a user enters a website address and when the website needs to fetch a resource from another internet location.

When a browser receives a request to resolve a domain name, it goes through the following steps:

  1. It checks the cache on the local machine in case the IP address for the particular domain has been requested before.
  2. If the IP address is not in the local cache, the browser requests to check the ISP's recursive DNS server cache.
  3. If the ISP does not have the necessary information, it forwards the request to outside DNS servers. These servers resolve the domain name and return the IP address information back to the web browser.

Note: The opposite of DNS lookup is the reverse DNS lookup process which involves resolving an IP address to its corresponding domain name. To learn more about the topic, read What is Reverse DNS and How Does It Work?

Why Is Reducing DNS Lookup Important?

Reducing DNS lookup time improves the performance of your website in a number of important ways, including:

  • Faster website loading - Reducing the lookup duration improves website loading times and shortens the waiting period before the website is accessible.
  • Faster component loading - Slow DNS resolution may delay the loading of some critical website components.
  • Reduced network latency - Poorly optimized DNS lookups can increase the time data travels from client to server and back.
  • Better server utilization - Optimized DNS lookups reduce the server load by limiting the number of processed DNS queries.

10 Tips on How to Reduce DNS Lookup

There are several ways to approach the problem of slow DNS lookup times, from choosing a better service provider to using optimization techniques and monitoring performance.

The following sections contain the 10 most efficient tips for reducing DNS lookup time.

Choose a Fast DNS Provider

Domain registrars offer a DNS solution for free when purchasing a domain. However, the registrar's DNS is often slow and inadequate for business use.

To improve DNS resolution speed, use a specialized DNS provider with a global network of servers, such as Cloudflare, Google, and OpenDNS. While these providers offer excellent performance, ensure you compare their speeds in your region before making a final decision.

Utilize DNS Caching

DNS caching is an optimization technique that stores previously resolved DNS queries in a local cache. This means that a web browser first checks the local cache to see if it contains the records about the website. DNS caching reduces the amount of DNS lookups and speeds up the resolution process.

Note: DNS cache can be corrupted for a number of different reasons, including network attacks or viruses. Learn how to flush the DNS cache on macOS, Windows, and Linux and fix cache-related problems.

Adjust TTL

The TTL (Time To Live) parameter determines the length of time a server retains the DNS cache. Domain owners can adjust TTL using the hosting provider's interface.

For example, the cPanel interface allows you to change TTL values in the Zone Records section.

Adjusting TTL in cPanel Zone Records.

TTL values that are too high or too low impact a website's performance.

  • Low TTL shortens the time cache spends on the server and increases DNS traffic.
  • High TTL slows down the website updates because the users keep seeing the cached website version.

Use DNS Prefetching

Some website components need to load external assets to function properly. This increases the number of DNS lookups while navigating the website and affects the performance. DNS prefetching allows you to specify the assets to load during idle times (e.g., while the visitor reads the page).

For example, add the DNS prefetch option in a link attribute using the rel tag, and place it in the <head> element of the web page. The following statement tells the web browser to prefetch the content from

<link rel="dns-prefetch" href="//">

Note: There is no need to use dns-prefetch with addresses from your domain since the domain has already been resolved if the browser can read the instructions from the header.

Enable Keep-Alive

The Keep-Alive directive tells the web browser to maintain an active connection with the server. Enabling Keep-Alive is useful if there is a single domain from which your website downloads multiple assets. With Keep-Alive, one DNS request covers all the assets instead of each asset requiring a separate lookup.

For example, on Apache servers, activate Keep-Alive by adding the following to the .htaccess file:

<ifModule mod_headers.c>
Header set Connection keep-alive

On Nginx, edit the keepalive_disable line in ngx_http_core_module to look like in the example below:

keepalive_disable none;

Reduce DNS Redirects

DNS redirects happen if a domain resolves to a different domain or IP address. Redirects result in additional DNS lookups and affect the loading times.

Minimizing the number of HTTP redirects between URLs eliminates unnecessary round-trip times and waiting periods for users.

Distribute Content via CDN

A Content Delivery Network (CDN) is a system that distributes website content across a global server network. By storing copies of website content on multiple servers around the world, CDNs can deliver the content to users from a server that is geographically closer to them. This reduces the distance that data needs to travel and improves load times.

Popular CDN providers are Stackpath and KeyCDN, alongside Cloudflare and Google.

Defer JavaScript Loading

Many JavaScript functionalities do not have to load immediately upon visiting a website. By deferring the loading of some JavaScript functionalities, the website can display the primary content more quickly to make the page functional sooner.

However, not all JavaScript is optional. When deferring it, ensure you created an exclusion list with the scripts necessary to load the website.

Use DNS Security Extensions (DNSSEC)

DNS Security Extensions (DNSSEC) provide a way to digitally sign DNS records and add another layer of security to DNS. DNSSEC helps prevent DNS spoofing and tunneling but also improves DNS lookup time.

When you generate a DNSSEC cryptographic key, ensure to add it to your domain's DS record. If your provider uses cPanel, the DNSSEC section is available in Zone Editor for each domain.

Editing DNSSEC in cPanel Zone Editor.

Use ANAME Records to Replace CNAME

CNAME (Canonical Name) is a DNS record that creates an alias for another domain. This type of record is frequently utilized when multiple services need to run from one IP address. However, the more CNAME records a website has, the bigger impact on its performance.

The ANAME record (A Record combined with CNAME) provides similar functionality. However, it maps directly to the root level, lowering the number of requests necessary to resolve a domain name.


After reading this article, you should know more about techniques to optimize the performance of your website by reducing DNS lookup time. Some tips in the article are easy to apply, while others require some strategic thinking.

If you are looking to improve your DNS design further, read about DNS Best Practices for Security and Performance.

Was this article helpful?
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.
Next you should read
What is a Domain Name System (DNS)
March 2, 2023

A Domain Name System (DNS) first emerged in the early 1980s. It represents a system of servers that store registered domain names and IP addresses.
Read more
DNS Record Types Explained
September 20, 2021

In this tutorial, we take you through a comprehensive alphabetical list of DNS record types, explaining how they work, and provide examples and use cases.
Read more
Troubleshooting DNS Issues
November 17, 2021

Most other network services, such as Web, emails, and file transfer, use DNS. A misconfigured DNS server can lead to critical connectivity issues. Thankfully, troubleshooting...
Read more
How to Use Linux dig Command (DNS Lookup)
May 23, 2024

The dig command in Linux is used to gather DNS information. It stands for Domain Information Groper, and it collects data...
Read more