X-DNS-Prefetch-Control
The HTTP X-DNS-Prefetch-Control response header is an unofficial HTTP header controlling whether the browser performs DNS prefetching for links on the page.
Note
The "X-" naming convention for HTTP headers, "X" referring to "experimental", has been deprecated and needs to be transitioned to the formal naming convention for HTTP headers.
Usage
DNS prefetching is a browser optimization where the browser resolves domain names for hyperlinks on a page before the user clicks them. Each DNS lookup adds latency, often tens of milliseconds, and prefetching eliminates this delay by completing the resolution in advance.
The X-DNS-Prefetch-Control header gives site operators explicit control over this behavior. Pages with many external links benefit from prefetching because the resolved addresses are ready when the user navigates. Pages handling sensitive information disable prefetching to prevent DNS queries from leaking the domains referenced on the page, as each prefetch sends a DNS query visible to network observers and DNS resolvers.
Browsers generally enable DNS prefetching by default for pages loaded over HTTP and disable prefetching for pages loaded over HTTPS. This header overrides the default in either direction.
The <link rel="dns-prefetch"> HTML element provides
per-link control for individual domains, while
X-DNS-Prefetch-Control sets the page-wide default.
Values
on
The on value enables DNS prefetching for all links on the
page. Browsers resolve the domain names of linked resources
in the background as the page loads.
off
The off value disables DNS prefetching entirely. No
background DNS resolution occurs for links on the page. This
is appropriate for privacy-sensitive pages, login forms, or
pages listing user-specific content where the linked domains
reveal information about the page contents.
Example
Enabling DNS prefetching on a page with many external links to improve perceived navigation speed:
X-DNS-Prefetch-Control: on
Disabling DNS prefetching on a page handling sensitive data, preventing DNS queries from revealing linked domains:
X-DNS-Prefetch-Control: off
Takeaway
The X-DNS-Prefetch-Control header determines whether the browser resolves domain names for links in advance, trading a small amount of DNS query visibility for faster navigation when the user clicks an external link.