views:

157

answers:

2

I've noticed that my pageview counts are being messed up by the pipe-lining feature in Firefox. People who visit using Firefox with pipelining enabled count two (or more) times for each visit.

What is the best way to detect or block these duplicate requests? I need to know how to block it on my server, not just how to disable pipelining in Firefox.

I'm using PHP and Apache.

+1  A: 

Consider using a non-logfile based stats solution, like google analytics.

This is really an issue with your stats package of choice, not firefox.

Frank Farmer
Josh Fraser
A: 

You can use the Apache KeepAlive Off directive to prevent Apache from leaving connections open after a request.

If you're stuck on an older 1.3 version of Apache, it's KeepAlive 0.

Update:

The "Context" info on both these links reads "Server Config." According to this page, that means you can't use them in .htaccess files.

If you can only change settings from .htaccess, I think you will need to use the SetEnv directive to set the nokeepalive environment variable. The examples on that page also show how to set variables for only specific files/paths or specific browsers by user-agent.

Tim Sylvester
Thanks! What would I add to my .htaccess file to add this?
Josh Fraser
I've added "SetEnv nokeepalive" to my .htaccess file. I want to do it that way if possible so I'm only turning off keep-alive for the pages that need it. This doesn't seem to be stopping the duplicate requests. I've tried setting the Connection header to "close" with PHP and that doesn't seem to be working either. Any other ideas?
Josh Fraser
Actually I take that back. It didn't work on MAMP, but it worked when I pushed it live. Thanks for your help!
Josh Fraser
The main Apache config can enable or disable individual options in the `.htaccess` files. You'll need either `AllowOverride All` or `AllowOverride FileInfo` (I think).
Tim Sylvester