I have an image based website that hosts multiple galleries. When a user clicks one of the images the views
property for the particular image is incremented. However, I noticed when using Firefox (14.0.0.1) it increments the views twice, whereas not-so-complicated browsers such as K-meleon increment the property once - as it should.
Someone then pointed out on stackoverflow that this is probably due to pre-fetching in modern browsers causing the PHP script that fetches the image from the database and increments the views to be executed twice. So, checking my apache access.log I noticed that Firefox does indeed request each image twice:
Firefox/14.0.1" ::1 - - [03/Aug/2012:16:41:37 +0100] "GET /imgsite/getImg.php?id=23 HTTP/1.1" 200 57362 "http://localhost/imgsite/index.php" "Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1" ::1 - - [03/Aug/2012:16:41:37 +0100] "GET /imgsite/getImg.php?id=23 HTTP/1.1" 200 57362 "-" "Mozilla/5.0 (Windows NT 6.1; rv:14.0) Gecko/20100101 Firefox/14.0.1"
I then read up on .htaccess and tried several methods of blocking the pre-fetch headers that Firefox (or chrome) sends, but shouldn't these headers show up in the above snippet? Nothing has worked so far. Here is my .htaccess file that is placed in the root HTML path of my website:
RewriteEngine On
RewriteCond %{HTTP:X-moz} prefetch
RewriteRule . . [F,L]
I've tried other and more extensive variants of the above, still to no avail. My apache setup allows .htaccess as the mod_rewrite.so line is enabled.
Everything I've seen plus rewrite not affecting anything is leading me to believe that this is not actually a pre-fetching issue.
If someone could shed some light on this issue I'd be very grateful. Thanks.