я писал что кэширует, можете сами протестировать вот этот код
<?php
session_start();
if(empty($_SESSION['captcha'])){
exit();
}
header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
header('Pragma: no-cache');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
$image=imagecreate(46,18);
imagefill($image,0,0,imagecolorallocate($image,255,255,255));
$code=(string)$_SESSION['captcha'];
imagestring($image,5,mt_rand(4,5),mt_rand(0,3),$code[0],imagecolorallocate($image,mt_rand(0,200),mt_rand(0,200),mt_rand(0,200)));
imagestring($image,5,mt_rand(14,15),mt_rand(0,3),$code[1],imagecolorallocate($image,mt_rand(0,200),mt_rand(0,200),mt_rand(0,200)));
imagestring($image,5,mt_rand(24,25),mt_rand(0,3),$code[2],imagecolorallocate($image,mt_rand(0,200),mt_rand(0,200),mt_rand(0,200)));
imagestring($image,5,mt_rand(34,35),mt_rand(0,3),$code[3],imagecolorallocate($image,mt_rand(0,200),mt_rand(0,200),mt_rand(0,200)));
imageline($image,mt_rand(0,46),mt_rand(0,18),mt_rand(0,46),mt_rand(0,18),imagecolorallocate($image,200,200,200));
imageline($image,mt_rand(0,46),mt_rand(0,18),mt_rand(0,46),mt_rand(0,18),imagecolorallocate($image,200,200,200));
imageline($image,mt_rand(0,46),mt_rand(0,18),mt_rand(0,46),mt_rand(0,18),imagecolorallocate($image,200,200,200));
imageline($image,mt_rand(0,46),mt_rand(0,18),mt_rand(0,46),mt_rand(0,18),imagecolorallocate($image,200,200,200));
imageline($image,mt_rand(0,46),mt_rand(0,18),mt_rand(0,46),mt_rand(0,18),imagecolorallocate($image,200,200,200));
imageline($image,mt_rand(0,46),mt_rand(0,18),mt_rand(0,46),mt_rand(0,18),imagecolorallocate($image,200,200,200));
header('Content-Type: image/gif');
imagegif($image);
imagedestroy($image);
?>
на h2m при неправильном вводе проверочного числа, и обновлении страницы, изображение не меняется, ну или по крайней мере не менялось, не смотря на то, что $_SESSION['captcha'] совершенно другое значение было, этот же самый код на другом хостинге, конкретно на джахост, работает без проблем