DNS Prefetching

DNS Prefetching

DNS prefetching means that a browser looks up a website's address data before the user even clicks. This makes page loading start a few milliseconds to tenths of a second faster.

Every website has a name like example.com, but computers on the internet find each other only through numbers. These numbers are called IP addresses. For a browser to load a page, it first has to have the name translated into such a number. To do this, it asks a special lookup service on the network, the Domain Name System, or DNS for short. This query usually takes only milliseconds, but it still delays the page from loading. DNS prefetching means: the browser asks this question in advance, for addresses it will probably need shortly.

Milliseconds you would otherwise just wait for

The name lookup sits right at the beginning of every connection. As long as it’s running, nothing else happens. Only afterwards can the browser establish the connection and request data. This waiting time is called latency. It doesn’t depend on bandwidth, but on how far a signal has to travel.

On good networks, a name resolution costs 20 to 120 milliseconds. On mobile networks it can take considerably longer, because the radio network first has to wake back up. That sounds like little, but it adds up. A typical news site loads content from ten or more different servers: images, fonts, video players, ads, analytics. Each of these servers requires its own request.

For website operators, this is real money. Studies by major online retailers have shown the same correlation for years: if a page becomes noticeably slower, more visitors abandon it. That’s why prefetching is a standard tool in load-time optimization, alongside image compression and caching.

What the browser looks up in advance

There are two approaches. In the first, the website itself provides a hint. The page’s source code then contains a line with the dns-prefetch instruction and an address. The browser interprets this as a recommendation: please look up this name in advance already. It does this on the side, while the page is still loading.

In the second approach, the browser decides on its own. It looks at the links on the current page and resolves their addresses in advance. If the user then actually clicks, the number is already sitting in the temporary storage, the so-called cache. That step is skipped entirely.

It’s important to draw the distinction: DNS prefetching only fetches the address, not any content. It doesn’t download an image or a page. Related techniques go further. Preconnect additionally already establishes the connection, including encryption. Prefetch downloads an entire file in advance. Of these three, DNS prefetching is the most economical, because it consumes almost no data.

Between load-time tuning and the privacy debate

Anyone who opens the developer tools in their browser and looks at the source code of a major site will usually find the prefetch hints directly in the head section. They have been built into all common browsers for over ten years. In the settings of Chrome or Firefox, the feature can be turned off, but it is active by default.

In technical discussions, the term comes up mainly in connection with Core Web Vitals. These are metrics that Google uses to assess a page’s user experience, and they influence search rankings. Anyone wanting to improve these metrics is almost always also working with prefetching.

There is, however, an objection. The browser queries addresses the user may never actually visit. The DNS provider, often the internet service provider, sees these queries regardless. From this trail, one can infer which page someone currently has open. There’s also a common misconception that more prefetching is always faster. Resolving a hundred addresses in advance mainly creates unnecessary network traffic. A few, well-chosen targets are the sensible approach.

Subscribe free. Unsubscribe the second it sucks.

High-signal news across AI, business, UX, and tech. Every morning.