I'm trying to reduce the bandwidth of a script, so my first thought was the "Last-Modified" and "HTTP_IF_MODIFIED_SINCE" headers. So i wrote the script, a snippet:
<?
$clm=strtotime($HTTP_IF_MODIFIED_SINCE);
if($clm>=$lastmodifiedpage)
{
header("HTTP/1.1 304 Not Modified");
exit;
}
else
{
header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodifiedpage) . " GMT");
}
?>
<body>
..
</body>
But there is a problem, when "$clm>=$lastmodifiedpage" is true, i send "Header("HTTP/1.1 304 Not Modified");" and then exit.
The webserver (apache) then generates a 500 error ("[Mon Oct 01 21:52:26 2001] [error] [client 127.0.0.1] malformed header from script. Bad header=HTTP/1.1 304 Not Modified: c:/php/php.exe").
Am i doing something wrong?