Guide to Reducing DNS Lookups
DNS lookups are an element that many website owners overlook. This is a mistake, however, because too many lookups can reduce the loading speed of your pages. Slow loading speeds can in turn lead to higher bounce rates and lower search engine rankings.
Fortunately, there are steps you can take to reduce your DNS lookups. There are also WordPress plugins that can handle this task for you. To get the job done effectively, though, you’ll need to first understand more about DNS lookups and what kind of response time you’re aiming for.
In this article, we’ll discuss what DNS lookups are and what a good DNS response time is. We’ll then explain how to reduce DNS lookups, and consider some of the plugins you can use. Let’s get started!
What Is a DNS Lookup?
Domain Name Servers (DNSs) are the foundation of the internet. They work like phone books for websites, linking them to their IP addresses. In turn, a DNS lookup is the process of finding the right IP address for a given website URL.
The responsibility of this lookup falls on the web browser. When you navigate to a website, your browser finds all the resources that require a DNS lookup. It then waits for the lookup to process before downloading any of those resources. The more lookups a website requires, therefore, the longer it takes for the browser to render its pages.
What Is a Good DNS Response Time?
Knowing what DNS lookups are can help you understand the importance of reducing them. However, you still need to check and see if they are currently causing a problem on your website. To do this, you can use an online testing solution such as UltraTools.
To run a DNS lookup test, you’ll simply need to provide your website’s URL. Then click on Go, and Ultra Tools will test your DNS response time:
While this provides some insight into your website, you still need to know what a good DNS response time is. These tools record lookups in microseconds. The lower the number is, the better the response time will be.
According to YSlow, DNS lookups generally take between 20ms and 120ms. If the test places your site’s response time on the higher end of that scale, you might want to consider reducing your lookups.
How Do I Reduce My DNS Lookups?
Reducing DNS lookups on your website can improve loading speeds and reduce bounce rates. If you use a page speed tester, many will provide you with recommendations on how to get started. Otherwise, here are some of the best steps you can take.
1. Use a Fast DNS Service
The first step is to reduce the response time for DNS lookups. One of the best ways to do this is by using a fast DNS service. Many people use the DNS provided by their domain registrars, such as Namecheap or GoDaddy. However, these free DNS options are often too slow.
Premium DNS providers generally have faster response times. For example, large providers such as Cloudflare have extensive infrastructure and global data centers. This can reduce the impact that DNS lookups have on the speed of your website.
2. Reduce the Number of Hostnames
One of the easiest ways to reduce DNS lookups is to get rid of requests for different hostnames. When you run your website through a speed test such as Google PageSpeed Insights, a list of hostnames and assets that trigger a DNS request is provided:
You can audit this list to reduce the number of requests. External requests for graphics such as social icon buttons each require a DNS lookup. During your audit, therefore, check to see if these resources are essential to your website. You can weigh the speed cost of the DNS lookup against the benefit of keeping the resource.
3. Host Third-Party Resources Locally
If you find that you still have a number of external resources after your hostnames audit, consider hosting the resources locally instead. Local hosting also provides more control over caching and the delivery of these resources, and eliminates the DNS lookup step.
To host the resources, download the files you need from whenever they’re currently stored, and upload them to your web server or CDN. If you use WP Engine, you can enable our CDN and host the files there.
If you have requests for frequently-updated scripts such as font libraries, however, hosting them locally might not be the best solution. As these resources are updated often, their scripts are better left alone, and other steps can be taken to reduce the impact of their DNS lookup.
4. Use DNS Caching
Another method of reducing DNS lookups is to take advantage of DNS caching. This stops the browser from requesting a lookup every time it requires an element on your website.
The DNS cache acts as storage holding the hostname for a set amount of time. When a browser requests the element, the cache provides the hostname instead of requiring a DNS lookup.
The length of the DNS cache is determined by the Time To Live (TTL). Not all DNS records should be cached for the same amount of time. Some commonly-accepted guidelines are:
- CNAME Records: 24 hours
- A and AAAA Records: Five minutes to an hour
- TXT Records: 12 hours
- MX Records: 12 hours
When setting up DNS caching, keep in mind that the TTL values will usually be shown in seconds. This will need to be taken into account when defining your values.
5. Make Use of DNS Prefetching
Prefetching enables browsers to perform DNS lookups in the background. As a user reads one web page, the browser will request prefetch elements. This is primarily used for links within your content.
It is easy to set up DNS prefetching, by adding the following code to the header of your single.php file (under Appearance > Theme Editor):
<!-- DNS Prefetching --> <link rel="dns-prefetch" href="//asset1.com"> <link rel="dns-prefetch" href="//asset2.com">
Paste the code in this file either at the top or bottom, and change asset1.com and asset2.com to the links you want to prefetch. You can also add as many additional URLs as you need.
Plugins to Reduce DNS Lookups
While it is possible to manually reduce your DNS lookups in WordPress, there are plugins that can make the process easier. These plugins won’t handle every aspect of reducing DNS lookups. However, they can automate certain steps, such as using browser caching and CDN hosting.
1. WP Rocket
WP Rocket is a premium plugin that works with WP Engine’s caching layers. It offers preloading of content and lazy loading for images. This speeds up the rendering of your website and reduces the DNS lookups.
LiteSpeed Cache offers browser caching and a free CDN cache. You can also use it to configure DNS prefetch if you are unsure about adding code manually. LiteSpeed Cache also enables code minification and object caching. You can even use the plugin to lazy load images, in order to further improve loading speeds.
Build Customized Digital Experiences on WP Engine
Reducing your DNS lookups is a key method of improving your website’s loading speeds. There are many steps you can take to reduce these lookups and speed up response times. Taking advantage of DNS caching and prefetching is important, but you also need a fast DNS service.
A quality hosting provider can help with that last step. At WP Engine, we offer built-in caching and DNS services. This leaves you with more time to focus on WordPress development and creating an incredible digital experience!