Sign in or Join FriendFeed
FriendFeed is the easiest way to share online. Learn more »
Kyle Laserdog
Strange PHP Puzzle. Why does the following script double count page views? - code: http://101010.org/phptest... link: http://101010.org/phptest...
Because the browser is making a HEAD request first that ends up running the script also? - Andy Bakun from Android
Heh, nah, that's not it. It's because the background is set to the URL "?", which is a relative URL to the same page. You almost got me there, my friend. - Andy Bakun from Android
It is the "?", but I'm still not sure *why* the browser(s) request that... If you set it to the equally valid URI "?dog=1", it no longer requests it. Something about "?" seems to be magic? - Kyle Laserdog
Is that browser dependent? - Andy Bakun from Android
It could be something related to the order in which things are downloaded as the page is parsed. What's the smallest possible URI fragment longer than just "?" that triggers the second download? Does "?x" do it -- no need for that to even look like a form variable assignment. - Andy Bakun from Android
Actually, I just retried my "?dog=1" test, and it is double counting again, so guess I was wrong about that. I'm still unclear exactly what the browser is hoping to retrieve from the uri though. A text file with a hex value? A style sheet? - Kyle Laserdog
What is weird, is setting BACKGROUND="?value=1" *doesn't* do anything... I'm still a little lost why "?" is so magical? kyle. - Kyle Laserdog from email
The "background" attribute of the "body" tag specifies an image to use as the background. The background color is given with the "bgcolor" attribute. - Andy Bakun
I was thinking it may have to do with caching. For some reason, "?" is treated as different from the current document, but "?value=1" is not. I was asking about the length because I was thinking there may be some kind of race condition in the parsing vs parallel downloading, and a longer URL delays is just long enough to know that it already has the current document. What happens if you add more stuff to the document in the "head" element, to make the document longer? - Andy Bakun
This doesn't seem to be much of a "PHP Puzzle", but rather a browser issue. BTW, it happens in Chromium on Linux also. And Opera 10. - Andy Bakun
Ahh, I was confusing background was bgcolor, makes sense. - Kyle Laserdog