Pages load twice on Firefox?
Asked Answered
U

9

18

I thought I had answered this question before thanks to StackOverFlow, but I hastily took an answer and it turns out not to be the real cause to my problem.

I have checked my Apache Access Log:

This is me browsing my web app on Google Chrome Browser.

127.0.0.1 - - [06/Jan/2010:22:17:35 +0000] "GET /webs/end/new.php HTTP/1.1" 200 2146
127.0.0.1 - - [06/Jan/2010:22:17:36 +0000] "GET /webs/end/settings.php HTTP/1.1" 200 4548
127.0.0.1 - - [06/Jan/2010:22:17:38 +0000] "GET /webs/end/index.php HTTP/1.1" 200 2042

This is me browsing my web app on IE7.

127.0.0.1 - - [06/Jan/2010:22:21:49 +0000] "GET /webs/end/settings.php HTTP/1.1" 200 4548
127.0.0.1 - - [06/Jan/2010:22:21:50 +0000] "GET /webs/end/index.php HTTP/1.1" 200 2042

This is me browsing my web app on Firefox.

127.0.0.1 - - [06/Jan/2010:22:18:08 +0000] "GET /webs/end/settings.php HTTP/1.1" 200 4548
127.0.0.1 - - [06/Jan/2010:22:18:09 +0000] "GET /webs/end/settings.php HTTP/1.1" 200 4548
127.0.0.1 - - [06/Jan/2010:22:18:10 +0000] "GET /webs/end/index.php HTTP/1.1" 200 2042
127.0.0.1 - - [06/Jan/2010:22:18:10 +0000] "GET /webs/end/index.php HTTP/1.1" 200 2042
127.0.0.1 - - [06/Jan/2010:22:18:11 +0000] "GET /webs/end/new.php HTTP/1.1" 200 2146
127.0.0.1 - - [06/Jan/2010:22:18:12 +0000] "GET /webs/end/new.php HTTP/1.1" 200 2146

This is just me clicking around. But notice that for every page request firefox seems to be loading the page twice and its effecting my PHP scripts as they are executing twice and making two insertions into my DB!

Why is the case? I am using Firefox 3.5.6. I am guessing this is a Firefox issue rather than a PHP/Apache one?

Underwent answered 6/1, 2010 at 22:27 Comment(3)
I really hope that the insertions you are talking about are strictly logging. If issuing GET requests causes some other data change then you have serious design issues here.Sapers
If issuing GET requests causes some other data change that's an entirely bogus statement. There is no difference whether you accept a series of input parameters from a form fieldset in post, or a query string collection on a get.Lina
I wouldn't say there is no difference. For one the post request would require a re-post (which most browsers would prompt the user about), while a GET request can be re-requested easily (unintentionally) and copying the URL and pasting it would re-request it. Also, someone could easily put a link in an img on their site with the src pointing to your site, and anyone visiting their site would post to your site. If your security is cookie based, their cookie would still be sent. So there is quite a lot of reasons to not use GET for posting data to be persisted or requests that will alter data.Chintz
R
13

What plugins have you got installed in Firefox, they may be making requests silently, especially FireBug. Try turning firebug off & see if it still happens.

As mentioned in the comment below, the latest version of FireBug shouldn't be doing this, so if it isn't, try disabling all your plugins (or running FireFox in safe mode) and see if it still happens

Rothschild answered 6/1, 2010 at 22:29 Comment(5)
With a previous version of Firebug I had this problem.Hangnail
Yeah, the latest version doesn't do this, so this may not be the problem.Rothschild
I have firebug and its version: 1.4.5, which is the latest version.Underwent
Alright, it seems to be the YSlow plugin! Damn it! Thanks guys. :)Underwent
@Underwent can you confirm this is due to YSlow? I've noticed this behavior before with Firefox and I currently have Firebug and YSlow also.Lina
R
12

Check out the Accept headers on the 2nd request. Does it look to be a request for an image? If so, you may have an empty "src" attribute on an "img" tag or an empty "url" definition in a CSS property which is causing the 2nd request.

More info here: http://icanhascode.com/2008/06/the-mystery-of-the-multiple-requests/

In general, this issue is a pain to track down.

Royo answered 6/1, 2010 at 22:35 Comment(1)
In my case background-image: url(""); was the issue. Fixed. Thanks.Norvell
D
7

I had the same problem another day. The solution was put

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

higher on the code. There was some css codes loading before it.

Disavowal answered 29/9, 2011 at 20:41 Comment(2)
I had to move it before a <!--[if lt IE 7]> statement.Straighten
Still its not working. do u have any alternate solution?Aetolia
R
5

This was a charset declaration issue for me too - take it out of all meta tags and declare it elsewhere!

Receptive answered 30/7, 2011 at 11:24 Comment(2)
This was my issue as well. changing: <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> to <meta http-equiv="Content-Type" content="text/html" /> fixed it.Nerte
This appears to be another long-standing Firefox bug that the development team are unable or unwilling to fix: Bug 61363Suspicion
S
2

As mentioned by Michael Morton, IMG tags with missing SRC can be a problem. Could also be empty HREF attributes on A tags. I've used jQuery to quickly identify them:

http://www.planbox.com/blog/development/coding/browser-send-same-request-twice-or-multiple-times.html

In short, run this in Firebug:

$('img[src=""],a[href=""]')
Sidestep answered 24/1, 2011 at 20:16 Comment(1)
<script src=""> tags can cause this tooBabar
S
1

This line is some Dreamweaver driven HTML and caused the browser to load twice (with doc type removed and firebug disabled):

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Stark answered 9/1, 2011 at 17:0 Comment(1)
this line:<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />Stark
T
0

None of these worked for me. Many hours of worry...here is what was my problem:

I had a HTML link with a button inside it. I found this was the problem because when I tested it on IE, the button didn't work (Buttons still worked in Firefox).

WRONG:

<a href=''><button class='btn'>Test</button></a>

RIGHT:

<a class='btn' href=''>Test</a>

WORKS now and no more double tap.

Tailored answered 1/2, 2012 at 16:13 Comment(0)
D
0

In my case I had duplicate tags like this:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<!-- more code -->

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

After removing it from my Blogger template, Firefox stopped re-loading the page.

Delphina answered 25/10, 2012 at 14:12 Comment(0)
Y
0

Am using mozilla firefox 46.0.1 and I got the same problem. But I noticed it occurred only when my php script had warning errors. Setting error_reporting(0); in my php script stopped the double execution of the script. After trying all the above suggestions, of course.

Yorker answered 17/6, 2016 at 8:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.