How to Speed Up DNS Lookup for Faster Websites
DNS lookup time is the first step in every web request. Before your browser can download a single byte from a server, it needs to resolve the domain name to an IP address. Slow DNS can add hundreds of milliseconds to your page load — and those milliseconds compound across every resource on the page.
What Is DNS Lookup Time?
DNS lookup time is the duration between your browser sending a DNS query and receiving an IP address in response. For most websites, this ranges from 20ms to 200ms depending on the DNS provider, geographic distance, and caching. You can measure it with browser DevTools under the Timing tab of any network request.
Why DNS Speed Matters
A typical webpage loads resources from multiple domains — your own domain, CDN domains, analytics services, font providers, and ad networks. Each unique domain requires a separate DNS lookup. If your page references 10 different domains and each lookup takes 100ms, that is up to one full second spent just on DNS.
Techniques to Speed Up DNS
1. Use a Fast DNS Provider
The single biggest improvement comes from switching to a high-performance DNS provider. Cloudflare (1.1.1.1), Google Public DNS (8.8.8.8), and AWS Route 53 consistently rank among the fastest. These providers have servers distributed globally, meaning queries are answered from a nearby location.
2. Enable DNS Prefetching
Add dns-prefetch hints to your HTML for third-party domains your page will need:
<link rel="dns-prefetch" href="//fonts.googleapis.com">
<link rel="dns-prefetch" href="//cdn.example.com">
This tells the browser to resolve these domains in the background before they are needed.
3. Reduce the Number of Domains
Every unique domain on your page requires a DNS lookup. Consolidate resources where possible — self-host fonts instead of loading from Google Fonts, use a single CDN domain instead of multiple, and remove unused third-party scripts.
4. Optimize TTL Values
Set appropriate TTL (Time to Live) values on your DNS records. A TTL of 3600 (one hour) or higher means resolvers cache your records longer, reducing repeat lookups. For stable records like your main A record, TTLs of 86400 (24 hours) are perfectly reasonable.
5. Use Preconnect for Critical Domains
For the most important third-party domains, go beyond prefetch with preconnect:
<link rel="preconnect" href="https://cdn.example.com">
Preconnect performs DNS lookup, TCP handshake, and TLS negotiation all in advance.
6. Implement DNS Caching on Your Server
If your server makes outbound DNS queries (for APIs, databases, etc.), install a local caching resolver like unbound or dnsmasq. This prevents repeated lookups for the same domains from your backend.
How to Measure DNS Performance
Use tools like dig with timing, browser DevTools, or online services like our Nameserver Lookup Tool to measure your DNS performance. Run lookups from multiple geographic locations to get a complete picture.
dig example.com +stats
Optimizing DNS is one of the highest-leverage performance improvements you can make. It costs nothing, requires minimal code changes, and benefits every single visitor to your site.