Reputation: 18408
Our site fetches resources from various first and third parties, like this:
<link rel="dns-prefetch" href="https://connect.facebook.net/">
Some of these URLs aren't used immediately on page load. Is it worth while to not DNS prefetch ever for some reason? Is the recommendation to just prefetch everything you'd possibly use?
Upvotes: 1
Views: 325
Reputation: 23078
One consideration if you are using hosted DNS is the number of lookups you generate. If you are paying per-lookup, you might not want to generate a bunch of dns lookups unless you really expect users to make real requests to them.
We had an issue with this at Stack Overflow from the network site links in the footer. That generated something like 1.8 million dns requests per hour, just for dns prefetching.
That would have led to a pretty massive dns bill, so we added x-dns-prefetch-control:off
to our default response headers to avoid those.
Another concern is privacy. If you have user-generated links, someone creative could make unique host names and use them to track people who see the link, without requiring them to actually click it. If you have prefetch links on https pages (which chrome does not prefetch on by default), the prefetching might reveal to an eavesdropper some information about relationships between sites.
Upvotes: 3