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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
fdaniels
Forum Newbie
Posts: 2
Joined: Sun Mar 09, 2003 10:52 am

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

Post 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
fdaniels
Forum Newbie
Posts: 2
Joined: Sun Mar 09, 2003 10:52 am

Found a solution

Post 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.
Post Reply