Recently I spent quite a long time tracking down a very unusual bug on a WordPress site I was coding up. I had installed the very handy WP-PostViews plugin, and was double checking I had installed it correctly by loading a post and watching the post counts go up.
Yet the strangest thing was happening – not only would the post I was currently viewing increase, but another post had its count going up as well!
Several hours’ debugging later I noticed the problem was only happening in Firefox, and narrowed down the problem, confirmed by another Web Developer’s blog post. WordPress by default adds various lines of code into the header of your website, including
<link rel="prev"...> and
<link rel="next"...> links, pointing to the previous and next blog entry from the one you are viewing. As of Firefox 3.5, anything found in a
<link rel="next"...> tag will automatically be “prefetched”.
The benefits? If a user is browsing through several blog posts, the posts will appear to load much faster than normal (as Firefox has already downloaded it for you).
The solution? Simple – just add the following code to your functions.php theme file:
or, for a version of WordPress before 3.0:
I will be doing so for all websites from this point onwards.