Why does my browser get an image twice?
<p>I have a php script which records an impression then displays an image.</p>

<pre><code>// Determine which header to send. 
$parts = explode('.', $tool-&gt;filename);
header("Content-Type: image/{$parts[1]}");
readfile('files/'.$tool-&gt;filename);
</code></pre>

<p>For some reason Firefox is getting the file twice. Here is the log.</p>

<pre><code>00:00:01.268    0.023   1211    182 GET 200 image/png   http://localhost/ap/image.php?aid=1&amp;t=6
00:00:01.347    0.162   1185    182 GET 200 image/png   http://localhost/ap/image.php?aid=1&amp;t=6
</code></pre>

<p>You can see they are got a split second apart. If I change the script as follows.</p>

<pre><code>// Determine which header to send. 
$parts = explode('.', $tool-&gt;filename);
//header("Content-Type: image/{$parts[1]}");
//readfile('files/'.$tool-&gt;filename);
echo 1;
</code></pre>

<p>Then the browser only reads the file once. Does anyone know why this is?</p>
