Page 1 of 1

header("HTTP/1.1 304 Not Modified", TRUE, 304) - n

Posted: Sun Mar 09, 2003 10:52 am
by fdaniels
Server: Apache/1.3.26 (Linux/SuSE) PHP/4.2.2

I have this code in the begining of my page:

Code: Select all

$row = mysql_fetch_object($result);

//last modified?
$gmt_mtime = gmdate('D, d M Y H:i:s', $row->modified) . ' GMT';

if (($_SERVERї'HTTP_IF_MODIFIED_SINCE'] == $gmt_mtime) and ($_SERVERї'REQUEST_METHOD']=='GET')) {
	header("HTTP/1.1 304 Not Modified", TRUE, 304);
	//header("Status: 304 Not Modified", TRUE, 304);
	exit();
}

$lastmod_header = "Last-Modified: " . $gmt_mtime;
Header($lastmod_header);
After the command "header("HTTP/1.1 304 Not Modified", TRUE, 304)" has been executed. Apache still returns an 200 status to client (checked with a HTTP sniffer). This of course makes the page seem empty in the client, instead of the client using its cache. Has anyone got any ideas about why?

I've allso tried "header("Status: 304 Not Modified", TRUE, 304);" - with same result.

No text or other headers has been echoed or sent earlier in code.

Many thanks,
Frode

Found a solution

Posted: Sun Mar 09, 2003 11:03 am
by fdaniels
After fumbling with this for several days, then posting this post, i found a n'th suggestion from a web page that worked:
header("HTTP/1.0 304 Not Modified");
If anyone want's to share some light on why this works, and not the other suggestions I'd be happy to hear it.