DNS Prefetch
Learn what DNS prefetch is, how it resolves domain names early to reduce latency, and how to implement it for faster page loads and better SEO.
DNS prefetch is a browser resource hint that tells the browser to resolve the domain name of a third-party origin before the user actually requests a resource from it. Implemented using , it performs the DNS lookup in advance so that when the browser later needs to fetch a resource from that domain, the IP address is already cached. A typical DNS lookup takes 20 to 120 milliseconds, and eliminating this latency for multiple external domains adds up quickly., it performs the DNS lookup in advance so that when the browser later needs to fetch a resource from that domain, the IP address is already cached. A typical DNS lookup takes 20 to 120 milliseconds, and eliminating this latency for multiple external domains adds up quickly.
Why It Matters for SEO
Modern web pages routinely load resources from multiple external domains — analytics services, font providers, CDN origins, advertising networks, and social media widgets. Each new domain requires a fresh DNS resolution, and these lookups happen sequentially as the browser discovers resources during HTML parsing. On pages with ten or more external origins, DNS resolution can add significant latency to the overall load time.
Faster DNS resolution contributes to lower time-to-first-byte for external resources, which cascades into better First Contentful Paint (FCP) and Largest Contentful Paint (LCP) scores. These Core Web Vitals metrics directly affect search rankings, making DNS prefetch a low-effort, high-return optimization.
How to Implement
Add DNS prefetch tags in your HTML head for domains you know will be needed:
<link rel="dns-prefetch" href="//fonts.googleapis.com" />
<link rel="dns-prefetch" href="//cdn.example.com" />
<link rel="dns-prefetch" href="//analytics.example.com" />
Use double slashes (//) rather than a full URL, as only the domain needs to be resolved. You do not need to specify a path or protocol.
For critical third-party domains that you are certain will be used on the current page, combine DNS prefetch with preconnect for even greater benefit: <link rel="preconnect" href="https://fonts.googleapis.com">. Preconnect performs DNS resolution plus the TCP and TLS handshakes, saving even more latency.
Best Practices
- Focus on third-party domains: DNS prefetch is only useful for external domains. Your own domain’s DNS is already resolved when the page loads.
- Limit the number of hints: Prefetching too many domains creates unnecessary network traffic. Focus on the four to six most important external origins.
- Pair critical domains with preconnect: For domains where you are certain resources will be loaded (like your CDN or font provider), use
preconnectinstead of or in addition todns-prefetch. - Audit your external domains: Use browser DevTools to identify all third-party domains your pages contact, then prioritize DNS prefetch for the ones that load earliest and carry the most critical resources.
- Do not prefetch speculatively: Only prefetch domains that the current page will actually use. Prefetching domains for pages the user might visit next wastes DNS cache space and creates unnecessary network requests.
- Test the impact: Measure TTFB for external resources before and after implementing DNS prefetch to quantify the improvement for your specific architecture.
DNS prefetch is one of the simplest performance optimizations available and requires no server-side changes — just a few lines in your HTML head that can shave meaningful milliseconds off your page load time.