I originally posted this over on the WordPress forums, and got no responses. Eventually I figured out what the problem was and fixed it, but thought I'd repost here in case anyone else is experiencing similar issues (I couldn't find any related articles in my initial search on the symptoms.)
My experience was during development of a WordPress plugin, but I can see the potential for this to affect any web development on pages containing relative links. I hope someone finds this helpful.
I have an interesting issue here. For some reason, in FireFox only, the page content being passed to my WordPress plugin is not correct for the page being viewed. It seems to be passing the content for the next page in the list, or something similar. The correct page content is actually presented in the browser, but not passed into the plugin, which is causing processing logic to fail in this browser.
This occurs on all pages in the site, regardless if I have placed any custom code or reference to the plugin into the page. I have been testing for days trying to figure out what/where the problem is occurring. All other browsers appear to work fine, but FireFox (and I have tested basically every version currently available to download). I don't believe it is a caching issue, as we've tried clearing, refreshing, changing/not using proxies, different computers, etc.
I have also noticed that the PHP
$_REQUESTvariables don't appear to be populating in FireFox, however the program is still able to process data, so it must be receiving the post data somehow.
Has anyone else experienced anything like this? or have any suggestions that I could try?
I am open to basically any ideas at this point, and your help would be greatly appreciated.
after a couple days more testing and placing debug print statements throughout the core code, I managed to track down the cause of this problem. I will document it here for others who may be interested or experiencing similar symptoms as google yielded no helpful results.
FireFox implements a prefetch feature that is not present in other browsers. This creates an additional HTTP request on the server, which was triggering my custom code (as it should, but not as I expected). Basically the second page request was causing my plugins session to reset itself, and preventing the plugin code from executing as normal.
The workaround solution I found is to check for the presence of a
$_SERVER['HTTP_X_MOZ']variable, which is only sent in the prefetch request, on the initial call to my plugin. If this variable is set, simply exit and don't execute any of the plugin code.
Another possible solution would be to prevent WordPress (or the template) from including the
link rel="next"or other tags that FireFox uses to trigger the prefetch, but this may not be ideal if such links are used for other purposes in the page.
Hopefully this will help someone else, as I found this issue to be a source of extreme frustration.