インプレッションを記録して画像を表示する php スクリプトがあります。
// Determine which header to send.
$parts = explode('.', $tool->filename);
header("Content-Type: image/{$parts[1]}");
readfile('files/'.$tool->filename);
何らかの理由で、Firefox がファイルを 2 回取得しています。これがログです。
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
1 秒も離れていないことがわかります。次のようにスクリプトを変更するとします。
// Determine which header to send.
$parts = explode('.', $tool->filename);
//header("Content-Type: image/{$parts[1]}");
//readfile('files/'.$tool->filename);
echo 1;
その後、ブラウザはファイルを 1 回だけ読み取ります。これがなぜなのか誰か知っていますか?