How to reduce DNS Lookup?

A is an element that webmasters often overlook. However, if well optimized, it can greatly contribute to website speed and overall performance. So today we are going to talk about how to reduce the DNS lookup (a process called DNS Lookup), to better understand how it benefits your site.

What is DNS Lookup?

DNS is fundamentally the backbone of our internet. Just as an address helps you avoid the use of coordinates, the domain name frees us from memorizing IP addresses.

Each domain is assigned an IP address. For example, when you type in your browser’s address bar, your ISP will request the nameservers associated with that domain. Without DNS, you would have to type 216.58.212.110 to get to the site.

This process of translating and finding which IP belongs to which website is what DNS Lookup is all about.

Therefore, before you can view and download all the resources with your browser, a DNS Lookup must be performed for each domain providing the information.

However, it is not necessary to extract the search from all resources. For example, when you make the following HTTP requests:

  • http://-dev-2.xyz
  • http://-dev-2.xyz/wp-content/themes/veggie-lite/style.css
  • http://-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, as in the example, you made five requests, there are only three unique domains in total. In other words, your browser only performs three DNS lookups:

  • http://-dev-2.xyz
  • http://platform.linkedin.com
  • http://platform.twitter.com

In general, when you visit a web page, the browser will request all resources with DNS Lookups. And you have to wait until all processes are completed before the browser can load anything.

This can take some time, especially if the page uses a lot of DNS lookups. And this event can cause slow loading times on the website.

Because it is important?

Having a fast-loading website not only provides a better visitor experience, it can also positively affect your website ranking.

Page load time plays an important role in website visitor retention and in . This is because a website takes more than three seconds to load.

According to a , it is reported that about 45% of visitors never visit the same website again if they encounter a bad experience. And significantly as one of the negative factors.

Google also uses page speed as . Slower page speeds can also further affect . That is why having a fast loading website is more than important for webmasters to be successful on the internet.

See also  18 Best Online Collaboration Tools for Remote Work

To find out how your website is performing DNS lookups and if you should be concerned about reducing them, you can measure your score using the . Here is an example we take for .

Reduce DNS Lookups Easily

Now you have learned about its function. All that remains is to reduce the DNS Lookups so that the performance of your website can improve.

1. Using a fast DNS service

Just like the , there are also reliable and less reputable DNS providers. And using a great one can significantly reduce each DNS Lookup. Popular DNS services include , , , and .

DNS providers work pretty much like a DNS provider: they have multiple points of presence (POPs) around the world. And the big providers, like Cloudflare, usually have a great infrastructure to deliver location-based DNS with low latency.

You can also check DNS providers for your preferred location, so you can have the best optimized speed, using tools like and .

2. Optimizing DNS Caching

Thanks to DNS caching (DNS Caching), you do not have to worry about the lookups that are performed on each page. This is because the same resource will not need to be downloaded a second time due to the caching process.

DNS Caching works similarly to a cache on a . With this method, DNS is served from a cache until it expires. You can also set the time of a DNS cache based on what we know as a time to live (TTL) value.

You can change the TTL value with your or third-party DNS providers to increase cache validity time and in turn reduce DNS Lookup.

If you are on , you can do this by changing the value of your DNS Zone Editor.

These are the most common TTL values:

  • 1800 seconds = 30 minutes
  • 3600 seconds = 1 hour
  • 14400 seconds = 4 hours
  • 43200 seconds = 12 hours
  • 86400 seconds = 24 hours

3. Optimizing DNS prefetch

Another way to reduce DNS lookups is by minimizing background activity while visitors are browsing the site. This method is known as DNS Prefetching.

See also  webinar archives

Prefetch allows a browser to fetch the assets needed to display the site’s content at a later time. It will start downloading other resources once the idle time has passed and it has cached these resources.

And when visitors click on a particular link that has been previously fetched, it enables faster data transfer that provides access to content instantly.

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

More importantly, DNS prefetching is also supported by the .

4. Enabling Keep-Alive

You can also reduce the DNS Lookup number. This is an always-on communication channel between a server and a browser, helping you load more asset files much faster.

For example, if you have an asset in n1.assetdomain.com and five resources in n2.assetdomain.com, will add up to six DNS requests. With Keep-Alive, those resources would be loaded as two requests.

It’s also worth mentioning that this active stream only uses a small message, so it consumes very little bandwidth. You can enable this feature on servers.

Apache

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

Header set Connection keep-alive

Nginx

On Nginx servers, look for the HTTP core module (ngx_http_core_module) and look for a line that looks like keep alive_disable. And you can change it as we show you in the following example:

keepalive_disable none;

5. Replacing CNAME with ANAME Records

CNAME records cause an additional lookup that can create a small amount of IP resolution delay. Having a few CNAMEs is generally normal. However, if your website has multiple CNAME records, you may want to consider removing them from your DNS records to reduce DNS Lookup.

Alternatively, you can use ANAME records. It shares the same functionality as CNAME, but at the root level, and this translates to faster IP resolution.

For example, if you have a setup for www.domain.com, with CNAME, you usually have to resolve the hostname first, then the IP address. And this requires two different sets of requests.

ANSWER SECTION: www.domain.com. 3599 IN CNAME domain.com. domain.com. 3599 IN A 40.71.11.131

See also  Top 18 eCommerce Trends You Should Know About in 2022

On the other hand, the ANAME record helps you to skip these requests and will instead return the following response:

ANSWER SECTION www.domain.com. 3599 IN A 40.71.11.131

If you use Cloudflare, it also provides a feature called sharing a similar function to an ANAME record.

6. JavaScript parsing deferral

This method allows you to fully load all website content before loading JavaScript, which also means that DNS lookups will not be called immediately. This can speed up the loading time of the website and, in turn, offer a better experience for the visitor.

In WordPress, you can use a plugin, like , to do the heavy lifting for you. But remember, you’ll also need to list the scripts you want to exclude from deferral.

conclusion

Ok, this was a lot of information, let’s do a quick recap on how to reduce DNS Lookups:

  • Using a fast DNS service: It is a sure way to have better DNS lookups, since the providers will take care of the essentials.
  • Optimizing DNS caching: This is another great way to cache your DNS. It works almost the same as a cache in WordPress.
  • Optimizing DNS prefetch: You can also preload the DNS, which allows you to offer a faster response. The main browsers support this method.
  • Enabling Keep-Alive: allows you to keep active dual-channel communication between a browser and a server. It also consumes very little bandwidth.
  • Replacing CNAME with ANAME records: You can also replace CNAME with a more effective ANAME record.
  • Deferring JavaScript parsing: and lastly, you can delay JavaScript so that it loads after the website content.

Do you have any experience with DNS Lookup optimization? Share it in the comments section below.

Deyi is a digital marketing enthusiast, with a background in web design, content creation, copywriting, and SEO. She is part of ‘s SEO & Localization team. In her free time, she likes to develop projects, read a book or watch a good movie.

Loading Facebook Comments ...
Loading Disqus Comments ...