Forum Moderators: coopster
HTTP/1.1 200 OK
Date: Sat, 30 Sep 2006 13:16:11 GMT
Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) PHP/
4.3.11
X-Powered-By: PHP/4.3.11
Last-Modified: Tue, 19 Jan 2038 03:14:07 GMT
Connection: close
Content-Type: text/html The code I use to retrieve and output the date must be wrong but I can't find the error. Thanks for help.:
$row_date['date'] = gmdate();
$colname_date = "1";
if (isset($_SERVER['date'])) {
$colname_date = (get_magic_quotes_gpc())? $_SERVER['date'] : addslashes($_SERVER['date']);
}
mysql_select_db($database_recettes, $recettes);
$query_date = sprintf("SELECT `date` FROM recettes WHERE receptID = %s", $colname_date);
$date = mysql_query($query_date, $recettes) or die(mysql_error());
$row_date = mysql_fetch_assoc($date);
$totalRows_date = mysql_num_rows($date);$last_modified = gmdate('D, d M Y H:i:s', $row_date['date']) . ' GMT';
// did the browser send an if-modified-since request?
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
// parse header
$if_modified_since = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
if ($if_modified_since == $last_modified) {
// the browser's cache is still up to date
header('HTTP/1.0 304 Not Modified');
exit;
}
}
header('Last-Modified: ' . $last_modified);
[edited by: dreamcatcher at 6:08 pm (utc) on Sep. 30, 2006]
[edit reason] No URLs, thanks. [/edit]
You just do the header('Last-Modified: ' . $last_modified); and the determination of whether to regard the page as modified or not modified will be done correctly, based on the $last_modified.
The format of the date in $last_modified must be an accepted format, though.
I think something like this works:
Sun, 06 Nov 2005 14:59:42 GMT