In this article I will show you how to resolve DNS before a webpage is actually requested by the browser. Before you continue with this article please read my article on preloading resources and prerendering recourses. In that article I explained critical time, caching requirement and many other basic concepts which will be used in this article.
What is DNS Resolution?
Dns resolution is a process of converting a domain/hostname to an ip address required to access a resource (this process is what converts a user friendly url like: http://qnimate.com to http://220.127.116.11 ); this requires a certain time and adds to the page loading process. Dns resolution takes very less time and bandwidth therefore pre-fetching large number of domain names will not harm user experience.
How to pre-fetch DNS?
We can pre-fetch DNS by using the rel=”dns-prefetch” attribute on the link tag.
<link rel='dns-prefetch' href='http://qscutter.com'>
A content provided(HTTP response) can force the browser not to DNS prefetch for the domain by using the x-dns-prefetch-control: HTTP header assigned to “off”.
This response domain name will not be pre-fetched.
You can again enable by setting the same response to “on”.