Search

4/22/2009

Blocking Mozilla / Google Prefetch

Blocking Mozilla / Google Prefetch

How to you tell the browser to prefetch a url?
<link rel="prefetch" href="http://url.to.prefetch/" />

How can I detect prefetching on my web site?
When mozilla does a prefetch, it sends a header X-moz: prefetch, you can then block based on that header. Google recommends sending a 404 back to block the prefetch.

Some interesting things about prefetch:
* Query Strings are ignored - if you have a page with a query string it will not be prefetched.
* HTTP only - https pages are not prefetched by firefox. ftp and other protocols are also ignored
* Cross domain cookie problems - With prefetching enabled, you may end up with cookies and web pages in your web browser's cache from web sites that you did not click on since prefetching happens automatically when you view pages.
* A good way to preload images - prefetching is a good way to preload images, instead of using javascript to do this because your browser can do it while it is idle.

沒有留言: