Chat +1-888-563-5277 Contact sales

What is DNS Lookup: how to reduce DNS lookups

DNS is an element that webmasters often overlook. However, when properly optimized, it can significantly improve site speed and overall performance. So, today we will talk about what a DNS lookup is and how it affects the operation of your site. We will also show you how to reduce the number of DNS lookups, which will most likely help you improve the performance of your resource.

What is DNS lookup?

DNS is the foundation of the Internet. Just as an address helps us avoid using geographic coordinates, a domain name frees us from having to remember IP addresses.

Each domain is associated with an IP address. For example, when you enter google.com into your browser’s address bar, your ISP queries the nameservers associated with that domain. Without DNS, you would have to enter something like 216.58.212.110 to get to the site.

The process of finding and determining which IP belongs to a particular website (domain) is called DNS lookup.

Thus, before you can view and load all resources using a browser, you must perform a DNS lookup for each domain that provides information on the page.

However, a lookup does not have to be done for every resource. For example, when you make the following HTTP requests:

http://hostinger-dev-2.xyz

http://hostinger-dev-2.xyz/wp-content/themes/veggie-lite/style.css

http://hostinger-dev-2.xyz/wp-content/plugins/mailchimp-for-wp/assets/js/forms-api.min.js

http://platform.linkedin.com/in.js

http://platform.twitter.com/widgets.js

Although you made five requests, we see only three unique domains in the example. This means that your browser only performs three DNS lookups.

http://hostinger-dev-2.xyz

http://platform.linkedin.com

http://platform.twitter.com

Usually, when you visit a web page, the browser requests all resources with DNS lookups. It must wait for all processes to complete before the browser can download anything.

This can take a while, especially on a page where there are many DNS lookups to do. As a result, website loading times may increase.

DNS lookup: simple ways to reduce DNS views

Now that you know what the DNS lookup is doing, it’s time to reduce the number of DNS lookups to improve the performance of your site.

1. Use Fast DNS Service

Just like with hosting, there are reliable and less reputable DNS providers. A good DNS provider can significantly reduce the number of DNS lookups. Some of the more popular DNS services include Cloudflare, WordPress.com, Edgecast, DNSMadeEasy, and DYN.

The way DNS providers work is very similar to how a CDN (Content Delivery Network) works – they have multiple points of presence (POP) around the world. And large vendors like Cloudflare usually have a large infrastructure of DNS servers around the world, which provides better response times and therefore better site loading.

You can also use tools such as DNSPerf and DNS SPeed Test to find the best DNS providers in your area.

2. Optimizing DNS Caching

 

Thanks to DNS caching, information about which IP address the domain is associated with is stored on the server for some time. As a result, DNS lookup takes less time.

DNS caching works in much the same way as WordPress caching. DNS information is kept on the server until it expires. By the way, you can set the time to store information in the cache, or TTL (time to live).

You can change the TTL value with your domain registrar or third-party DNS providers. By increasing the cache duration, you will reduce the number of DNS lookups, and, accordingly, the lookup time.

If your site is hosted by Hostinger, you can change the value in the DNS zone editor.

DNS Prefetching Optimization

 

Another way to reduce DNS lookups is to minimize background activity while visitors are browsing the site. This technique is known as DNS prefetching.

Prefetching allows the browser to get the possible addresses of the content on the page (images, scripts, etc.) that it needs to display later. The prefetching engine tries to resolve domain names before the user tries to follow the link and stores this information in the cache.

And when a site visitor clicks on a link while trying to navigate to a pre-allowed domain, they have instant access to the content.

You can add a DNS prefetch to a specific URL by adding a rel = tag to the link attribute. If you are using WordPress, you can add the following line to your site header:

Most importantly, DNS prefetching is supported by most modern browsers.

Enabling Keep-Alive Mode

You can also reduce the number of DNS lookups by enabling Keep-Alive. It is a constantly active communication channel between the server and the browser, helping to load more resource files much faster.

For example, if you have one resource at n1.assetdomain.com and five resources at n2.assetdomain.com, together they will make six DNS lookups. With Keep-Alive, these resources will be downloaded as two requests.

It is also worth noting that this kind of active transfer uses only a small fraction of the bandwidth since the requests are packed into one tiny message. You can enable this feature on Apache and Nginx servers.

Apache

To enable Keep-Alive on Apache server, add the following code to your .htaccess file:

Header set Connection keep-alive

Nginx

For Nginx servers, find the main HTTP module (ngx_http_core_module) and then a line that looks something like keep alive_disable. Change it as shown in the example below:

keepalive_disable none;

Replacing CNAME Records with ANAME Records

CNAME records create an additional lookup that can cause a slight delay in IP resolution. A small number of CNAMEs is fine. However, if there are too many such records on your site, remove them from DNS to reduce the number of DNS queries.

Alternatively, you can use ANAME records. They have the same functionality as CNAME, but at the root level, which means faster resolution of IP addresses.

CNAME records are used to link domain aliases to the canonical domain. For example, let’s take www.domain.com with customized CNAME records. To resolve an IP address, you first need to resolve the hostname, which requires two sets of different requests.

ANSWER SECTION:

www.domain.com. 3599 IN CNAME domain.com.

domain.com. 3599 IN A 40.71.11.131

The ANAME record, in turn, allows these requests to be skipped and instead returns the following response:

ANSWER SECTION

www.domain.com. 3599 IN A 40.71.11.131

If you are using Cloudflare, then you will be provided with a function called CNAME Flattening, which is analogous to ANAME.

Lazy Loading JavaScript

This method allows all site content to be fully loaded before JavaScript is loaded. This means the DNS lookup will not be invoked immediately either. This practice can speed up website loading and in turn improve the visitor experience.

In WordPress, you can use the Async JavaScript plugin to do all the work for you. But remember that you will also need to list any JS scripts that you want to exclude from the deferral.

Conclusion

 

Thus, DNS lookup is a concept that describes one process – a search in a kind of “telephone directory” of the Internet, the domain name system, information about which IP belongs to a particular site (domain).

A DNS lookup consists of multiple DNS lookups that are sent from server to server until the required information is found. The longer the search, the longer the page takes to load, which can negatively affect the experience of site users. Let’s reiterate how you can reduce the number of DNS queries and improve the performance and load speed of your site.

Using a fast DNS service is a surefire way to improve your DNS lookup as the ISPs take care of the optimization.

Optimizing DNS caching is another great way to improve DNS lookups. Works in much the same way as WordPress cache.

DNS prefetching – speeds up response delivery by pre-resolving domain names on the page. All major browsers support this method.

Keep-Alive mode – allows you to maintain active two-channel communication between the browser and the server. It does not consume much bandwidth.

Replace CNAME with ANAME records – You can also replace CNAME with a more efficient ANAME record.

Lazy Loading JavaScript – Finally, you can defer JavaScript so that it loads after the site’s content has loaded.

Your Guide to Data Breach Response

Your Guide to Data Breach Response

Data breaches have become more prominent in number and impact. That’s why a quick...

Read More
iOS 15 and Effects on Email Campaigns

iOS 15 and Effects on Email Campaigns

iOS 15 is the recent Apple operating system update that includes major changes for...

Read More
Mailchimp Authentication Setup: Step by Step

Mailchimp Authentication Setup: Step by Step

Mailchimp is an automated email marketing platform that’s used by businesses to reach their...

Read More
×