2

I made a list of all domains that resources on my site may use.

How do I add the link-tags for dns-prefetch for best practice?

1) Can I simplify life and output them all on every page? How painful is it to prefetch domains that may not be needed on the user's visit (e.g. a youtube player on some sub page). My thought is that dns resolving is cached in the browser for ~90(?) minutes...

2) Should I prefetch only domains that are referenced in the html directly, or also those that are needed after an action like click on a play button (e.g.) googlevideo.com for when a youtube player is started).

3) How to handle CDN subdomains like s.ytimg.com? I guess it's not enough to prefetch ytimg.com (if not even useless when this domain is never used alone)? All hope is lost for unguessable subdomains like a1339.phobos.apple.com I guess.

1
  • 1
    If you think this is really a performance issue for you, why not run a cacheing nameserver on the host, and let those FQDNs which are actually looked up often stay in cache automatically?
    – MadHatter
    Commented Aug 5, 2016 at 11:09

1 Answer 1

1

The performance issue will be negligible after the first prefetch has been done for each domain. The purpose of the prefetch is to speed up later linking in the page if the user clicks on a link or accesses a static resource that is on another DNS address as the initial fetching of the DNS record has already been done and is already cached in the computers DNS cache.

There is no need to prefetch domains for very busy and fast services like YouTube etc as these are already exceptionally fast for DNS resolution as many ISP's have those addresses cached in their local DNS caches rather than needing to send the browser to the SOA DNS server first to get the address.

As for CDN subdomains you do need to prefetch the absolute DNS that will be used and not just the parent domain but this depends on the CDN you are using as well as to if you need to use prefetch or not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.