为什么我的浏览器会得到两次图像


Why does my browser get an image twice?

我有一个php脚本,它记录了一个印象,然后显示一个图像。

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

出于某种原因,Firefox 两次获取该文件。这是日志。

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

你可以看到它们相隔一瞬间。如果我按如下方式更改脚本。

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

然后浏览器只读取文件一次。有谁知道这是为什么?

出于测试目的,请尝试通过以下方式从控制台启动您的 Firefox

firefox -safe-mode -no-remote

以暂时禁用所有扩展。也许其中一个扩展导致了这种情况。