Index: modules/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.650 diff -u -p -r1.650 node.module --- modules/node.module 18 May 2006 14:58:57 -0000 1.650 +++ modules/node.module 23 May 2006 01:45:00 -0000 @@ -386,6 +386,8 @@ function node_load($param = array(), $re $node->$key = $value; } } + + drupal_set_cache_date($node->changed); } if ($cachable) { Index: modules/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment.module,v retrieving revision 1.459 diff -u -p -r1.459 comment.module --- modules/comment.module 20 May 2006 08:14:09 -0000 1.459 +++ modules/comment.module 23 May 2006 01:45:01 -0000 @@ -296,7 +296,9 @@ function comment_form_alter($form_id, &$ function comment_nodeapi(&$node, $op, $arg = 0) { switch ($op) { case 'load': - return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid)); + $comment = db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid)); + drupal_set_cache_date($comment['last_comment_timestamp']); + return $comment; break; case 'prepare': Index: includes/bootstrap.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v retrieving revision 1.99 diff -u -p -r1.99 bootstrap.inc --- includes/bootstrap.inc 7 May 2006 00:08:36 -0000 1.99 +++ includes/bootstrap.inc 23 May 2006 01:45:01 -0000 @@ -323,7 +323,7 @@ function cache_get($key) { variable_set('cache_flush', 0); } - $cache = db_fetch_object(db_query("SELECT data, created, headers, expire FROM {cache} WHERE cid = '%s'", $key)); + $cache = db_fetch_object(db_query("SELECT data, created, timestamp, headers, expire FROM {cache} WHERE cid = '%s'", $key)); if (isset($cache->data)) { // If the data is permanent or we're not enforcing a minimum cache lifetime // always return the cached data. @@ -369,9 +369,9 @@ function cache_get($key) { */ function cache_set($cid, $data, $expire = CACHE_PERMANENT, $headers = NULL) { db_lock_table('cache'); - db_query("UPDATE {cache} SET data = %b, created = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, time(), $expire, $headers, $cid); + db_query("UPDATE {cache} SET data = %b, created = %d, timestamp = %d, expire = %d, headers = '%s' WHERE cid = '%s'", $data, time(), drupal_get_cache_date(), $expire, $headers, $cid); if (!db_affected_rows()) { - @db_query("INSERT INTO {cache} (cid, data, created, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $cid, $data, time(), $expire, $headers); + @db_query("INSERT INTO {cache} (cid, data, created, timestamp, expire, headers) VALUES ('%s', %b, %d, %d, '%s')", $cid, $data, time(), drupal_get_cache_date(), $expire, $headers); } db_unlock_tables(); } @@ -503,13 +503,13 @@ function drupal_page_header() { if ($cache = page_get_cache()) { bootstrap_invoke_all('init'); // Set default values: - $date = gmdate('D, d M Y H:i:s', $cache->created) .' GMT'; + $date = gmdate('D, d M Y H:i:s', $cache->timestamp) .' GMT'; $etag = '"'. md5($date) .'"'; // Check http headers: $modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] == $date : NULL; if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) && ($timestamp = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) > 0) { - $modified_since = $cache->created <= $timestamp; + $modified_since = $cache->timestamp <= $timestamp; } else { $modified_since = NULL; @@ -549,7 +549,7 @@ function drupal_page_header() { } else { header("Expires: Sun, 19 Nov 1978 05:00:00 GMT"); - header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); + header("Last-Modified: " . gmdate("D, d M Y H:i:s", drupal_get_cache_date()) . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); @@ -558,6 +558,34 @@ function drupal_page_header() { } /** + * Set cache date + */ +function drupal_set_cache_date($date = 0) { + static $cache_date = 0; + + if ($date > $cache_date) { + $cache_date = $date; + } + + return $cache_date; +} + +/** + * Get cache date + */ +function drupal_get_cache_date() { + $date = drupal_set_cache_date(); + $time = time(); + + if ($date < $time && $date > 0) { + return $date; + } + else { + return $time; + } +} + +/** * Define the critical hooks that force modules to always be loaded. */ function bootstrap_hooks() {