Today I saw this snippet in the HTML source of a webpage:
<!-- prefetch dns -->
<link rel="dns-prefetch" href="//s3.amazonaws.com">
<link rel="dns-prefetch" href="//cdn.api.twitter.com">
<link rel="dns-prefetch" href="//graph.facebook.com">
<link rel="dns-prefetch" href="//connect.facebook.net">
<link rel="dns-prefetch" href="//api.pinterest.com">
<link rel="dns-prefetch" href="//google-analytics.com">
How much can you gain by doing this? I haven't seen this before, nor in the Yahoo! Developer Networks guidelines for optimization. The only thing that seems related is "Reduce DNS Lookups".
In a similar fashion, why doesn't these services expose an IP address to their services and avoid the DNS look-up altogether?
DNS-prefetch is an attempt to resolve domain names before resources get requested. This could be a file loaded later or link target a user tries to follow.
Preload is an early fetch instruction to the browser to request a resource needed for a page (key scripts, Web Fonts, hero images). Prefetch serves a slightly different use case — a future navigation by the user (e.g between views or pages) where fetched resources and requests need to persist across navigations.
I guess that this gives parallel DNS lookup of those links later used for a bunch of JavaScript's.
Direct IP-numbers does not work well with CDN's. They resolve to a host close to the caller. If you are in the US they give you the IP of a server in US. If you are in Europe they give you the IP of a server in Europe, etc. You can't cheat like that with direct IP numbers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With