WebPagetest Forums
dns-prefetch. Anyone familiar? - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: Web Performance (/forumdisplay.php?fid=3)
+--- Forum: Optimization Discussions (/forumdisplay.php?fid=5)
+--- Thread: dns-prefetch. Anyone familiar? (/showthread.php?tid=169)



dns-prefetch. Anyone familiar? - p83822 - 02-15-2010 08:25 PM

Hi colleagues and friends.

<link rel="dns-prefetch" href="//somedomain.com">

anyone give a summary on this and save me a job sniffing browser traffic? (Which I can't do from my work PC for usual corporate network pain reasons <groan>).

I guess I'm after 3 things:

- Does this block download in any subtle way?
- Is this FF only?
- Does it force the browser to DNS lookup when it encounters the link (or only when it's DNS cache is empty/stale?)

DNS lookups can be pretty frightful in some parts of the world, so I'm looking to see what we can do to alleviate it.

BR
Neil


RE: dns-prefetch. Anyone familiar? - p83822 - 02-18-2010 06:11 AM

If I've asked something daft and everyone's too polite to point it out, please say. Smile

Thanks

N


RE: dns-prefetch. Anyone familiar? - pmeenan - 02-18-2010 10:45 AM

Nope, you've asked a good question, I just don't know the answer but please do post back what you find. You may also want to post it to the yahoo exceptional performance group which is more of a mailing list and has a bunch of people on it as well.

From everything I have read it should be completely asynchronous and start the lookups as soon as it parses it (so higher up in the head the better). Also sounds like Chrome supports it so it's not limited to firefox. Unfortunately pagetest only works with IE so it won't be useful for testing it but it could be a very interesting win for non-IE browsers (particularly for pages that reference a bunch of domains).

Wireshark would be best to be sure but depending on the level of access you have on the box you could use something like http watch (trial available) or if you can't install that, something like Google's Page Speed plugin for chrome (will at least tell you how it performs in chrome).

-Pat


RE: dns-prefetch. Anyone familiar? - p83822 - 02-22-2010 05:58 AM

OK

So I had a test page with some 20 discrete prefetches in the head and 1 image in the body.

- IE does not prefetch, as Pat indicated
- Chrome does prefetch and it does seem to do it asynchronously (as per http://dev.chromium.org/developers/design-documents/dns-prefetching )
- Safari does not prefetch

However I just could not seem to get FF3.6 to do it (network.dns.disablePrefetch setting was not set i.e. I had default settings)

I tried disabling FF cache using network.dnsCacheEntries = 0.
I tried restarting FF
I tried clearing the windows DNS cache
...and all the combinations thereof.

BR
Neil


RE: dns-prefetch. Anyone familiar? - hsiboy - 02-25-2010 08:00 AM

DNS pre fetch is something i have been looking into, and so far as in browser dns pre fetch tags go, its still a dream...

Meanwhile Google have re invented the DNS server with one that incorporates DNS pre fetch.

Normaly when the ISPs DNS server goes back to the authoritative host to get the DNS record it just caches it without inspecting the TTL on the record. For our site that is 300 seconds, which is deliberately quite short. The next time a user requests the DNS record from their ISPs DNS server, only then does it inspect the TTL and if its expired then it will go back to the authoritative host.

Google found that their googlebot was spending more time looking up DNS records, than it was spidering pages. So they made their DNS server inspect the TTL of the record and before it expired fetch it again so the cache is kept hot.

If you give yourself a tight target like a "1 second homepage" then you may see 700ms wasted in DNS resolving. If thats the case give the google DNS server a go. its available on 8.8.8.8 and 8.8.4.4 its quite shocking the difference it can make.

Stuart


RE: dns-prefetch. Anyone familiar? - pmeenan - 02-25-2010 10:19 AM

I think you may be crossing some wires. The Google DNS service is something your users would use and configure for, not something you can do from the server side to improve your performance (unless you encourage all of your users to switch DNS providers).

I agree that they are doing a lot of really cool things in the space, it's just not something site owners can directly leverage.

-Pat


RE: dns-prefetch. Anyone familiar? - p83822 - 04-12-2012 03:47 AM

[attachment=182]I thought I'd have another look at this, now that dns-prefetch is official HTML5. I ran the following in FF (because I know how to disable FF's dns cache.) (And yes, this is truly vile!)

My expectation was that the look ahead preparser would recognise nodejs.org and http://www.w3.org as being in the html, but would not recognise http://www.w3schools.com as it is in the JS. My understanding being that look ahead preparsers do not read JS.

To my surprise, the DNS lookup for http://www.w3.org occurs after the sleep. (VRTA graphs this beautifully - see attached.) Pic1 is with dns-prefetch tags commented out, Pic2 with them in.

The horrid code?. Enjoy:

<html>
<head>
<meta charset="utf-8">
<!--<link rel="dns-prefetch" href="//nodejs.org">
<link rel="dns-prefetch" href="//www.w3.org">
<link rel="dns-prefetch" href="//www.w3schools.com">-->
</head>
<body>

<img src='http://nodejs.org/images/logo.png'/>

<script type="">
(function() {
var startTime = new Date().getTime();
while (new Date().getTime() < startTime + 1000);
}())
</script>

<img src='http://www.w3.org/2008/site/images/twitter-bird'/>

<script type="text/javascript">
(function() {
var d = function() {
var img = document.createElement("img");
img.src = "http://www.w3schools.com/images/w3schoolslogo.gif";
var s0 = document.getElementsByTagName('script')[0];
s0.parentNode.insertBefore(img, s0);
};
setTimeout(d, 1000);
}())
</script>
</body>
</html>
Daftness. Nothing will happen during the sleep. D'oh! Nice to know that the prefetch directive now though.


RE: dns-prefetch. Anyone familiar? - p83822 - 04-12-2012 07:01 PM

How's about this one? Same behaviour - no auto prefetch for the second image from http://www.w3.org. Same behaviour in FF and Chrome. So, had naturally assumed that only needed explicit prefetch for my js loaded resources...

<html>
<head>
<meta charset="utf-8">
<!--<link rel="dns-prefetch" href="//nodejs.org">
<link rel="dns-prefetch" href="//www.w3.org">
<link rel="dns-prefetch" href="//www.w3schools.com">-->
</head>
<body>

<img src='http://nodejs.org/images/logo.png'/>

<script type="text/javascript">
(function () {
var astr = "a" + "l" + "e" + "r" + "t" + "('blocking io');",
f = new Function(astr)();
}());
</script>

<img src='http://www.w3.org/2008/site/images/twitter-bird'/>

<script type="text/javascript">
(function() {
var d = function() {
var img = document.createElement("img");
img.src = "http://www.w3schools.com/images/w3schoolslogo.gif";
var d0 = document.getElementsByTagName('div')[0];
d0.parentNode.insertBefore(img, d0);
};
setTimeout(d, 1000);
}());
</script>

<div/>
</body>
</html>


RE: dns-prefetch. Anyone familiar? - pqdbr - 04-17-2012 02:59 PM

(02-18-2010 10:45 AM)pmeenan Wrote:  Nope, you've asked a good question, I just don't know the answer but please do post back what you find. You may also want to post it to the yahoo exceptional performance group which is more of a mailing list and has a bunch of people on it as well.

From everything I have read it should be completely asynchronous and start the lookups as soon as it parses it (so higher up in the head the better). Also sounds like Chrome supports it so it's not limited to firefox. Unfortunately pagetest only works with IE so it won't be useful for testing it but it could be a very interesting win for non-IE browsers (particularly for pages that reference a bunch of domains).

Wireshark would be best to be sure but depending on the level of access you have on the box you could use something like http watch (trial available) or if you can't install that, something like Google's Page Speed plugin for chrome (will at least tell you how it performs in chrome).

-Pat

I don't know if this is an old post, but pagetest now works with Chrome and FF as well, right ?

If so, I'd be interested in knowing how this affects performance. Any idea if a site using static0-static3 subdomains could benefit from this ? I think so ?