There are several ways to optimize your WordPress website, some of which may be more important than others. One of the most important factors that is often overlooked is the reduced load time of DNS Lookups. Like TTFB and latency, which we’ve talked about a lot before, DNS Lookups load time is very effective in getting the first website information. So today we decided to look at how to reduce the load time of DNS Lookups and increase their speed, and together we will explore the importance of this factor in the speed of the website. Read more about TTFB in the article TTFB Time Improvement.
What is meant by DNS Lookups?
To understand what we mean by DNS Lookups, you must first become familiar with the basic DNS working method. In general, DNS stands for Domain Name System, which means the domain name system, which is basically known as the backbone of the Internet. If you have followed my articles in SEO teaching, I always refer to the notebook, a notebook for the whole world, to explain how DNS works. All the websites and domains you see on the Internet are specifically linked to an IP address.
For example, when you enter a Google.com address on the Internet, DNS queries are requested by your ISP for specific information about the semi-servers. The domain information is then collected by the IP behind the scenes of the server, which you can also enter with the IP 188.8.131.52 due to the special IP address of your Google website. Logging in with an IP is not as fun as it sounds.
When you enter a request to enter a website, the first thing your ISP requests from the destination server is to request the DNS information of the website. But keep in mind that there is no need to re-search DNS for each source. For example, consider the following HTTP requests:
Given that there are 8 HTTP requests above, however, given that there are 3 domains in requests, 3 searches for DNS information are required.
If you need more and simpler explanations on how DNS Lookups work, read the Reduce DNS lookups article.
Search DNS in Pingdom
I have written an article about searching for DNS as well as a general explanation about the Pingdom tool, which I suggest you read. Below we show how to display the above requests in the speed test tool on the Pingdom site. DNS in pink cascade analysis is pink and its speed analysis is in milliseconds. When you first evaluate your website in Pingdom, it will receive and review your full IP address and other DNS queries. Note that you do not need to start evaluating DNS for each evaluation, for example the cdn.wpdev.ink domain. This is exactly what DNS does, you only need to load it once for each domain. There are 8 HTTP requests above, of which only 3 require DNS requests.
Each time the DNS is checked by the browser and server, extra time is added to the website load and no information is loaded until the DNS is fully checked.
For example, in the 3 DNS check above, one of the 3 DNS took 300 milliseconds to check, which is the time without considering the DNS time required for other domains. So you can see the effect of DNS checking on speed quite clearly.
When you re-evaluate your website with Pingdom, you will notice that the DNS information in Pingdom has been cached and you no longer need to reload it. This is one of the reasons why it is recommended to evaluate your website several times in Pingdom. As you can see below, the DNS load time in the image below is 0 seconds. This is the part that most people think is wrong, but don’t worry, we’ll talk more about DNS caching.
Check DNS in GTMetrix
In general, each speed check website has its own type of check, but most of them tell you the speed of checking DNS. Below is how to display the DNS data load time in GTMetrix. DNSs are marked in green on a millisecond basis. Regarding the DNS section in GTMetrix as well as other errors in GTMetrix, the SEO teaching website has compiled a complete set of valuable information for you, which it is recommended that you review.
Check DNS in WebPagetest
WebPageTest is a very accurate and efficient tool in the field of checking DNS and cascading chart analysis for the site. If you are interested, you can also use this website due to the number of servers around the world, as well as general analysis. All the information on the user’s website has become very popular. DNS load time information in this tool is placed in the DNS Lookup column in milliseconds. For example, we randomly selected a news website and after checking with this tool, the DNS load time reached 6.5 seconds!
Unfortunately, most news websites do not have optimization and the external requests of the websites are very high. However, as you can see, our news website under study takes much longer than the acceptable amount of DNS load for users to load this factor. That’s why we say DNS is so important, because it can make your website too slow or even down.
How to reduce DNS Lookups load time
Learn more about how DNS works. Now it’s time to talk about how to reduce load time and increase DNS Lookups speed, DNS Lookups load speed has different names such as:
- Minimize DNS Lookups
- Reduce DNS Lookups
Trick 1: Use a fast DNS provider.
One of the important points about DNS is that DNS, like hosting hosts, has fast and slow providers. This is the first thing you need to consider on your website.
DNS registered by GoDaddy and NameCheap typically perform very poorly. DNS providers, like CDNs, have different POPs around the world. The best and fastest DNS providers are amazon, Cloudflare, Dyn and DNS Made Easy. All of these providers have extensive infrastructure for the fastest returns.
With that in mind, we started looking at individual DNS providers. After our review, we found that speed does not make much difference in commercial DNS providers, but in free DNS providers other than CloudFlare, the others have a slower speed. So if you have a very important business, it is recommended that you use a commercial DNS provider.
Some of the top providers are faster in some areas than others, and it’s very important how you look at DNS loading, global or local.
The DNSPerf website is a good tool for comparing different types of DNS providers and helps you choose the best provider. Did you know that you can use the DNS section of Cloudflare without using other features?
Trick 2: Change TTL inputs to use DNS cache
Fortunately, as described above, once DNS is cached in your browser, you no longer have to worry about reloading DNS checks on your other pages, just loading your website for the first time. DNS caching is exactly like crawling a website and stays in the browser until it expires. The DNS cache is defined by something called Time to live, which stands for TTL. If the TTL of a website is high, the browser will start checking the DNS again.
You can change the TTL inputs of your website to improve the DNS cache. Note that ISPs automatically cache your DNS, but you can help by changing the TTL inputs.
- 300 seconds = 5 minutes
- 1800 seconds: 30 minutes
- 3600 seconds: ساعت 1 hour
- 43200 seconds: 12 hours
- 86400 seconds: 24 hours
30 minutes per hour is most used for TTL. However, some users use less TTL due to the constant updating of their website. For example, Cloudflare saves TTL by 5 minutes by default. It’s a good idea to look at your other records and adjust them to your website usage. for example :
- Records A and AAAA: These records are often changing and 5 minutes is enough to cache them.
- CNAME Records: Most of the time these records do not change and I think 24 hours is great for caching.
- MX Records: It is rare to change these records and usually 12 hours is recommended for caching.
- TXT Records: It is rare to change these records, and 12 hours is usually recommended for caching.
In general, there is no right or wrong answer when it comes to TTL. But you can help the DNS cache by slightly modifying the TTL inputs and testing it.
Trick 3: Reduce the number of domains (hostnames)
One of the best ways to reduce DNS check time is to reduce the number of requests to different domains, which means generally reducing the number of domains linked to the website. The DNS check time is not so important as the number of requests, the important thing is the number of domains that the smaller the DNS check time, the lower it is. Check your website with a tool like Pingdom and identify important requests. Given that DNSs are based on IPs, you may be wondering why people use domains in their DNS. Make sure your DNS is set on one domain because IPs can be changed (for example, by hosting), but domains do not change and will always remain, and are better suited for caching files.
Trick 4: Use high-speed DNS replacement services.
In this case, you can use alternative services such as Hotjar, which do exactly the same thing, which is better in terms of both DNS loading speed and performance. It is very important that when you add a plugin to WordPress, it does not harm the performance of your website.
Trick 5: Transfer and host resources on the CDN
One of the easiest ways to speed up your website is to transfer as much of your resources as possible to your CDN provider. When you test your website in Pingdom, you see the amount of requests your website has for each domain. As you can see, below 93.8% of our requests are loaded from CDN. One request is from our host and one request is from Google Analytics. By transferring resources to the CDN, you limit and speed up DNS checking time to a single DNS provider. In this article, we have fully explained the reasons for using CDN.
However, the above website was a specific website, but in general it is not always possible to transfer information completely to CDN.
Most of the time you will load the resources that need to be loaded on external servers into the CDN. However, we recommend that you load the resources from the CDN as long as it does not damage your website. Most of the time we find that WordPress users load most of their resources on their hosts and ignore the CDN. By doing this you can also use HTTP / 2 and parallelization features.
Here are some tips to help you do just that.
We see on most websites today that use the Awesome font as the icon font on their website. But the problem with using these fonts is that most WordPress websites load completely directly from the user’s host and users do not know how to load them via CDN, in which case we recommend using plugins such as CDN Enabler. use.
Another way is to use cdnjs or bootstrapcdn to load font files via public CDN, click on public CDN for more information.
Since adding a link through the above CDNs adds a record to your DNS, it is recommended that you use your own CDN. (cdnjs uses Cloudflare servers and Bootstrap CDN uses MAXCDN servers)
If you use WordPress, you must be familiar with its default user interface, Gravatars. One of the best ways to get rid of the loading time of Gravatars DNS is to use lazy loading of comments, which we have also published in SEO teaching, its activation tutorial, and you can benefit from our excellent tutorials by referring to the lazy loading post of images. However, this does not reduce your DNS load time and only delays the load until the user scrolls to the comments section. So by doing this, you have reduced the DNS load time in the initial load of your website. I suggest you watch our article on speeding up WordPress views.
With Google Fonts you add an extra request to load styles for Google Fonts to your website. Then you have to download the fonts via gstatic. Try to load these types of fonts locally on your web host or CDN and prevent them from loading through other intermediary websites. This has its advantages and disadvantages, but in general it helps a lot to speed up your website.
Awesome fonts, Google fonts and gravatars were just a few examples of ways to reduce DNS load time. Did you try to load most of your resources through CDNs?
Trick 6: Pre Use Prefetching DNS.
Another way to reduce DNS load time is to use DNS Prefetching. This will allow you to load DNSs in the background of your website. This is possible by adding a few lines of code to your website. Note the following code:
<!– 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=”//cdn.domain.com”>
Just note that DNS prefetch is not supported in some browsers, such as Opera Mini, but do not worry, this lack of support will not affect the performance of your website, but for users who use that browser, DNS will load later.
Or if you are using WordPress version 4.6, you can get help from published resource tricks. Developers using the wp_resource_hints method can load dns-prefetch, preconnect, prefetch or prerender in the WordPress background by adding new domains and links.
Trick 8: Use flat ANAME and CNAME records.
Some DNS providers have additional records that can speed up DNS loading.
Use ANAME records in the DNS Made Easy provider:
ANAME RECORDS Show you the overall performance of CNAME RECORDS at the ROOT level. For example, suppose you have configured your CNAME domain as www.domain.com. First www. It must find the names of the hosts and then connect to the IP. So this is a 2 step process. In ANAME, the initial stage of CNAME is removed and connected directly to the IP, which speeds up. Exactly like the following example:
www.domain.com. 1799 IN CNAME domain.com.
domain.com. 1799 IN A 192.168.1.2
www.domain.com. 1799 IN A 192.168.1.
CNAME alignment with Cloudflare:
Similarly, Cloudflare has a service called Flat CNAME that does exactly the same thing as ANAME and displays data at the apex level.
In general, DNS Lookups are one of the most overlooked factors in most websites, but with a little attention, a webmaster can help load his or her website. Just know how DNS works, there are slow and fast DNS providers, and learn how to fix DNS check problems.
Let us know if you can find a better way to improve your DNS checking time.