Posted on March 14, 2010 by Elliott Brueggeman4 Comments »

A few months ago while debugging a Wordpress site and outputting queries into a log, I noticed that queries were getting fired for pages that I wasn’t even looking at. After a baffling search, I found out that Firefox was prefetching the next post based on the rel=”next” meta tag.

For example, on my Fish Taco Blog site, this is an example rel=”next” meta tag that Wordpress automatically generates:

<link rel='next' title='Chat Chew' href='http://www.fishtacoblog.com/new-york/chat-n-chew/' />

When viewing a post in the single.php template, Wordpress will output rel “next” and “prev” tags by default. Firefox then consumes this information and makes the decision to load the next page before you browse to it. The idea is that once you are browsing posts, you may be more likely to visit the next post in the sequence, possibly via the next post link that is present in many Wordpress themes, and it will now be locally cached by Firefox, speeding up page load time for when you actually do click on it.

Sure, this wouldn’t hurt most blogs – it’s a feature that enhances the user experience. However for high traffic blogs, and Wordpress sites that aren’t built on the traditional post concept, this feature is unnecessarily and possible harmful to performance.

To remove these tags from Wordpress site, add the following to your theme’s functions.php file:

For Wordpress versions 3.0 and above:

//remove auto loading rel=next post link in header
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');

For older Wordpress versions:

//remove auto loading rel=next post link in header
remove_action('wp_head', 'adjacent_posts_rel_link');

Here’s Mozilla’s background information on prefetching, and it should be noted that this currently only happens in Firefox, not Internet Explorer.

Comments

  1. Matthew on 19 Jun 2010 at 10:38 am

    Thanks for explaining the reason for this meta-tag… There is way too much clutter in the WP header already to justify this tag too.

  2. david on 27 Jul 2010 at 11:22 pm

    This prefetching was driving me crazy till I saw the link tag and realized that that’s what it must be doing!
    Anyway, you might want to mention that in WP 3.0, the action name has changed, it is now:

    remove_action(’wp_head’, ‘adjacent_posts_rel_link_wp_head’);

  3. Sergio on 27 Aug 2010 at 5:01 am

    @david: I don’t know where did you find such information, but I was looking for this about two hours, so THANK YOU!

    Does it exists an official document for ALL these parameters?

  4. Joakim Eriksson on 31 Aug 2010 at 12:31 am

    Wow, that saved my DAY, or week acctually! :-)
    I’ve searched for hours, both the net and in my code to find out where the heck the code was added.

    I build a webbshop for my client. The last page places the order, sends an order mail and empties the SERVER SESSION.
    Being on the next last page, Firefox rendered that last page, as soon as one entered the email-adress, the mail was sent and the session was emptied.

    Your my hero!

    Keep up the good work!

    best regards!
    /jocke

Leave a Reply - Registration Not Necessary