DNS prefetching or rel=dns-prefetch is a way to speed up a web pages by pre-resolving DNS that suggest browser to resolve the DNS of specific domain prior to being loaded or called. Basically, it will allows you to resolve domain names (perform a DNS lookup in the background) before a user clicks on a link. Just simply adding a rel=”dns-prefetch” tag in the header of your WordPress site to speed up your web pages load when they are using different domains for page resource.
Before we proceed to add DNS Prefetching in WP Rocket Plugin, let’s get the basic understanding and why we need it.
Why DNS Prefetching is Very Important and Useful?
Let’s make it simple and easier for you guys to understand on why we need DNS Prefetching in order to improve a web pages loading speed to the next level perhaps.
Example, you website have bunch of js and css files that are used for you page loads and most of these files loaded from 3rd party domain (another domain from yours) like adsense, seo tools, analytics etc..
Obviously, you likely do not know which files the browser will try to load first in any kind of scenario right? Well, in this kind of situation DNS Prefetching is a perfect by resolving the DNS without actually grabbing a file.
This means that whatever actual file the browser gets first, it will be ready and have the DNS resolved much earlier. So, the resource can be retrieved faster than usual case.
DNS Prefetching basically will gives you more control of what the browser will loads when loading your page rather than leaving it to users clicked.
Enable DNS Prefetching in WordPress with WP Rocket Plugin
DNS Prefetch is supported by most of caching plugin for WordPress especially WP Rocket. Even all major browsers does support DNS Prefetching except iOS Safari, Opera Mini and Android Browser.
You can easily addingg DNS Prefetching by clicking “Preload” tab on left sidebar of WP Rocket plugin setting page (WordPress > Setting > WP Rocket > Preload).
Then adding domains, one per line. Do not add the prefix https:// or https://, this way it will resolve no matter the protocol could be.
Done! Simple right? You won’t need to scratch your head and adding new “rel=dns-prefetch” tag on your wp-header file inside your theme. Most of caching or performance plugin does support DNS Prefetching features and you can simply add new domains per line.
Another things, you might want to check with your theme that certain things like Google Fonts already been added in their theme’s code. Thus, you can view your source code and do quick scan just to ensure you aren’t trying to add the tag twice.