Forum Moderators: coopster

Message Too Old, No Replies

php-generated images & connection

images seem to be prolonging connection

         

mincklerstraat

1:46 pm on Oct 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have a very simple php image script that's loaded with the js onload event - the point is that the pages are given cache info and are cacheable, but the image produced by the script is non-cacheable, so it can deliver pageview & referrer info to the database.

At the moment, the image script (

c.php
) goes like this:

/* caching headers */
header('Content-Type: image/gif');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
/* content length header */
header('Content-Length: '.filesize('trans.gif'));
readfile('trans.gif');
/* db stuff to log pageview and referrer */

trans.gif
is a 1x1 transparent gif. At the moment, when I view the page with firefox, the status bar shows 'Transferring data from [domain.com]', and doesn't go away. Getting this file directly just shows the image (have changed it to a visible image to make sure it works), it loads nice and quick.

The included .js is:


function stim() {
cimg=new Image();
reff=document.referrer;
cimg.src="http://www.bugfoo.com/c.php?ref="+reff;
}

and it gets called with
<body onload="stim()">
.

What's likely here? Am I reaping the consequences of being a javascript moron, or is it likely that somehow filesize isn't returning the correct content length? Any input much appreciated.

nb: just ditching the content-length header doesn't change anything

dmorison

7:13 am on Oct 30, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



At the moment, when I view the page with firefox, the status bar shows 'Transferring data from [domain.com]', and doesn't go away.

I see this all the time in Firefox - it could just be a manifestation of this bug:
[bugzilla.mozilla.org...]

mincklerstraat

7:24 am on Oct 31, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks dmorison, it looks like it's ff's bug. That's a load off my chest.