tags:

views:

252

answers:

4

Ok this is weird.

If I make a request to a page, where it's text/html, firefox makes one request.

If I make a request to a page, where it's application/xml, firefox makes two requests.

In IE, Google Chrome, it one makes one in both cases.

Any ideas why the two requests, and how I can force just the one?

+1  A: 

I've had a similar issue if the encoding of the page didn't match the <meta> tag. If the page was encoded using default windows encoding, but the meta tag specified UTF-8, then firefox would stop downloading once it reached a non-ascii character (e.g. æ,ø or å) and it would redownload the page from the beginning. This would mess up view counts and lots of other logic since the server side script would run twice.

It might be that if you do not start your page with <?xml ?>, but claim that it is, then Firefox will redownload the page again as html (text/html) and process it as html.

Marius
A: 

Found the problem.

The XML packet I was returning had a root node of <feed>

Firefox passes this twice for some reason, maybe as it's trying to identify if this is a valid ATOM/RSS feed. If not, just displays instead?

Changing root node to something else fixed the problem.

Thanks Marcus for starting me in the right direction.

Dave Quested
A: 

Maybe you're making the request in a way that cause HTTP Access Control features to fire?

It is a fairly new standard, and new in [FF3.5][2] that can cause double GET requests.

In case you can sniff the requests server side: see if they contain the Origin: header.

[2]: https://developer.mozilla.org/En/Server-Side_Access_Control Server-Side Access Control

conny
A: 

In my case it was a wrong content-type header "image/jpg" sent with PHP-generated image. Double requests gone after I changed the type to "image/jpeg"

More info about this bug... https://bugzilla.mozilla.org/show_bug.cgi?id=236858

Alex