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 downsides? Nearly everything else. The WP-PostViews will have inaccurate post counts. Other forms of tracking may also be affected (though javascript-based tracking methods like Google Analytics are not affected). Sites with a huge number of visitors where any performance optimisation is vital are badly affected – the load on your server is doubled when viewing a single post. Could there be side effects with caching plugins? Perhaps. And I’m sure the list goes on.

The solution? Simple – just add the following code to your functions.php theme file:

remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');

or, for a version of WordPress before 3.0:

remove_action('wp_head', 'adjacent_posts_rel_link');

I will be doing so for all websites from this point onwards.

Get actionable tips to grow your website

Thoughtful weekly insights (no hype!) on improving your website