Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
The changes committed at #2259103: set cache->created with microtime(), not time() have broken page caching.
In drupal_serve_page_from_cache() (bootstrap.inc) we have:
// See if the client has provided the required HTTP headers.
$if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE;
$if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE;
if ($if_modified_since && $if_none_match
&& $if_none_match == $etag // etag must match
&& $if_modified_since == $cache->created) { // if-modified-since must match
header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified');
drupal_send_headers($default_headers);
return;
}
The value of $if_modified_since (above) will always be an integer, and thus it will never be equal to $cache->created, with the result that Drupal will never return a 304 not modified even if the cached data have not changed.
I think the proper fix is in Drupal core - but in the meanwhile, can we at least make this higher precision optional?
Comment | File | Size | Author |
---|---|---|---|
#1 | memcache-optional-timestamp-precision-2335727.patch | 524 bytes | wodenx |
Comments
Comment #1
wodenx CreditAttribution: wodenx commentedComment #2
Jeremy CreditAttribution: Jeremy commentedThis needs to be reviewed and if indeed page caching is broken, properly fixed. Tagging for next release.
Comment #3
wodenx CreditAttribution: wodenx commentedRelated drupal core issue: #2337449: Conditional Requests are broken when a cache back-end uses a higher precision timestamp
Comment #4
Jeremy CreditAttribution: Jeremy commentedComment #6
Jeremy CreditAttribution: Jeremy commentedI've moved the higher precision timestamp into its own variable called "created_microtime", restoring "created" to be compatible with core.
http://cgit.drupalcode.org/memcache/commit/?id=a6a1ca8