Prevent Firefox prefetching in WordPress

Using WordPress as an application layer today I came across an issue where everything was going fine and dandy in my browser testing, until I got to Firefox, which was odd since it was working fine in IE7-9.

The app was fairly simple, users arrive on the app, enter some details (not a username and password) that log them into WordPress, they complete a form that updates their details and on successful completion they go to a ‘thank you’ page that logs them out.

In Firefox I was able to get to the form stage, but no further, it kept kicking me back to the login, no matter what I did on the form.

Each state of the application was a page and of course WordPress being helpful added theĀ rel="next" links to the header that Firefox went off to prefetch. I had written the app to log users out when they reached the thank you page so Firefox was logging me out as soon as I had logged in.

Luckily it was a fairly simple fix to remove the next and prev links using the following in the theme’s functions.php:

remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head' );