DNS

How to Reduce DNS Lookups and Speed Them Up

A Domain Name System (DNS) is a fundamental part of the internet. Without it, people would have difficulty accessing websites. When users want to visit a specific site, their web browser will perform a DNS lookup to find the domain’s matching IP address.

During a DNS lookup, a web browser will request resources needed to display the web page. This process can take some time to complete, which may lead to increased site loading time and reduced website conversion rates.

Server

However, there are some practices site owners can do to ensure DNS lookups don’t slow down their sites. For example, it’s crucial to point your domain name to your web hosting to avoid errors and lagging speeds.

This article will cover six best practices to help reduce and speed up your site’s DNS lookups.

How Does a DNS Lookup Work?

A DNS lookup is the process of translating human-readable domain names into IP addresses. It might seem like an instant process, but it actually consists of several steps. In this section, we will elaborate on how a DNS lookup works.

Let’s say you want to visit a website, such as example.com, so you type the URL into the browser’s address bar. After hitting enter, your web browser submits a DNS request.

In the process of a DNS request, your internet service provider (ISP) will contact nameservers connected to the site’s domain. Then, the nameservers will send back the necessary IP information to your web browser.

A web browser will also request resources needed to display website content after a DNS lookup in the form of HTTP requests, such as:

  • http://example.com
  • http://example.com/wp-content/themes/veggie-lite/style.css
  • http://example.com/wp-content/plugins/mailchimp-for-wp/assets/js/forms-api.min.js
  • http://platform.linkedin.com/in.js
  • http://platform.instagram.com/widgets.js

There are five HTTP requests in the example above. However, there are only three domains – example.com, platform.linkedin.com, and platform.instagram.com. This means the web browser only performs three DNS lookups.

Server DNS

6 Best Practices to Reduce DNS Lookups

Now that you understand the process of DNS lookups, we will go over the tips to minimize them.

Keep in mind that some of the points below involve technical configurations. So, consider creating a backup of your website first to avoid any errors. Alternatively, apply the changes to a staging environment to avoid compromising your site’s performance.

We also recommend checking your DNS response time to identify the best approach to reduce your site’s DNS lookups. To do that, utilize tools like Pingdom, GTMetrix, and WebPageTest.

1. Use a Fast DNS Provider

Choosing a fast DNS provider is highly recommended to keep your website performance optimal while significantly reducing DNS lookups.

There are many DNS providers to choose from, but not all are reputable and reliable. We recommend comparing some of the most popular DNS providers, such as Cloudflare, Edgecast, DNS Made Easy, and Amazon, and making your choice from there.

Moreover, use a tool like DNS Checker, Dotcom-tools, and DNSPerf to help you find the right DNS provider.

A DNS provider service works similarly to a Content Delivery Network (CDN) service in that it has points-of-presence (POPs) distributed worldwide. For instance, premium DNS providers, like Cloudflare and Amazon, provide comprehensive physical infrastructure designed to deliver low-latency DNS lookups.

DNS Cache

2. Take Advantage of DNS Caching

With the help of DNS caching, you can improve DNS lookup time. A DNS cache acts as a temporary database stored on a local computer containing records of recently visited websites. It can minimize the frequency of DNS lookups when users visit a site.

As a website owner, you can set the length or time-to-live (TTL) of the DNS cache. There are different ways to change the TTL values – through a domain registrar, third-party DNS providers, or a web hosting control panel.

Remember to choose the TTL value for the DNS cache carefully. The following is a list of common TTL values:

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

Server Wires

3. Optimize DNS Prefetching

Consider using DNS prefetching to reduce DNS lookups.

With the help of DNS prefetching, a web browser will load resources in the background before that resource is explicitly requested. It also works on any particular link that has been prefetched. So, when users click on that link, the web browser will deliver the content faster.

For WordPress website owners, consider installing a DNS prefetch plugin like Perfmatters. It is a premium plugin that provides many features to speed up your site. Once activated, you can start adding domains to prefetch. To do that, you need to add one domain per line like the following:

//fonts.googleapis.com
//www.google-analytics.com
//cdnjs.cloudflare.com
//www.googletagmanager.com

If you prefer a manual method, you can add URLs you want to include in the DNS prefetching using the <link> element and entering a link on the rel= attribute. For example, add the following lines under the <head> element inside the functions.php file:

<head>
<!– Prefetch DNS for external assets –>
<link rel=”dns-prefetch” href=”//fonts.googleapis.com”>
<link rel=”dns-prefetch” href=”//www.google-analytics.com”>
<link rel=”dns-prefetch” href=”//www.keycdn.com”>
</head>

4. Enable Keep-Alive

Enabling the Keep-Alive function is another method to help reduce DNS lookups. This function maintains active communication between a server and a web browser. Therefore, your website can load more resources faster, eventually improving the site load speed.

For example, you have six resources at n1.domain.com and two other assets at n2.domain.com. This means your site will have eight DNS requests in total. By applying Keep-Alive, you can minimize the DNS requests to just two.

If you use an Apache server, you will need to add the following code in the .htaccess file:

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

As for Nginx server users, open the HTTP core module ngx_http_core_module. Then, look for a function that is similar to keep alive_disable. Change the function with the following line:

keepalive_disable none;

Server Code

5. Delay JavaScript Parsing

Deferring JavaScript processing can improve your site load speed. It also helps minimize DNS lookups by not requesting them immediately.

You can suspend or delay JavaScript parsing without performing any technical tasks. If you use WordPress, simply install the Async JavaScript plugin.

You need to configure the plugin first to make it work. On your WordPress dashboard, go to the plugin settings and check Enable Async JavaScript. Then, choose Defer under the Async JavaScript method. Click Save Changes to confirm the settings.

6. Changing CNAME with ANAME Records

CNAME is an additional DNS record from DNS providers like Cloudflare and DNS Made Easy. Having a few DNS CNAME records is considered normal. However, if you have multiple CNAME records, we recommend removing them to help reduce DNS lookups.

It is also possible to change CNAME records with ANAME records since it has the same functionality. The difference is that ANAME records are at the root level and translate to a faster IP resolver.

If you configure your domain with CNAME records, it usually needs to map to a hostname first and then the IP address. Therefore, it requires two different requests. Take a look at the following example:

www.yourdomain.com. 3599 IN CNAME yourdomain.com
yourdomain.com. 3599 IN A 30.70.10.130

Meanwhile, ANAME records can directly translate to the IP address. The request looks like the following:

www.yourdomain.com. 3599 IN A 30.70.10.130

To modify your DNS records from CNAME to A, you can use your DNS provider.

Conclusion

DNS is one of the major factors affecting site performance, which is why speeding up DNS lookups can help boost your website’s overall user experience.

In this article, we have gone over how to reduce DNS lookups and learned the process of a DNS lookup. Here is a recap of six best practices to reduce DNS lookups:

  • Use a fast DNS provider.
  • Make use of DNS caching.
  • Optimize DNS prefetching.
  • Enable Keep-Alive.
  • Delay JavaScript parsing.
  • Change CNAME with ANAME records.

We hope this article has helped you understand the best methods to reduce DNS lookups on your website.

Similar Posts

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.