How HTML 5 link prefetching can make your site load faster with one line of code
keyboardy.com
keyboardy.com
http://www.google.com/search?q=hacker+news
there is a link element added to prefetch news.ycombinator.com.
<link href="http://news.ycombinator.com/" rel="prefetch">
I assume if you aren't careful in your logs, you could be overestimating your traffic.I guess some people with top search results can infer some pretty accurate stats from this.
* If this becomes popular it has the potential to skew logs and stats. Consider what happens when a bunch of prefetch requests are made to one of your pages, but the user never actually visits the page. The server (or stats package) doesn’t know the difference.
To clear this up, Firefox sends along an HTTP header, X-moz: prefetch, but you need some logic on the server side to detect it.
Javascript on the page isn't run until you actually visit the page, so that will be unaffected.
I don't think this is a big issue since JS-analytics are already superior to server-side log-analysis (caching alone).
Neat little tidbit though, I'm interested in how this work with regard to the cache control/expiry headers (for dynamic pages).
It (and its brother, rel="prev") are meant to inform the browser (which then hopefully informs the user, but that never took off) of what the next or previous page is (in contexts where that makes sense). Maybe it's the next page of an article (evil!), or the next blog post in line. Whatever.
Anyway, this has been around for a while, even mentioned in this post from 2008: http://diveintomark.org/archives/2008/06/21/minimalism
So it's more accurate to say that Firefox likes to prefetch pages, and will use <link rel="next"> tags to guide it. If you're going to be pre-fetching pages anyway, that seems a reasonable enough way to decide what to fetch, but I agree that I'd prefer pre-fetching to be off.
Does make it feel super-snappy though
in .htaccess
RewriteCond %{X-moz} ^prefetch
RewriteRule ^.* - [F]Check out Ghostery for Firefox.
Only server-side is reliable.
Maybe the "annoy a minority of people with tight bandwidth-caps"-attack isn't all that big of a threat.