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?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

wodenx’s picture

Status: Active » Needs review
FileSize
524 bytes
Jeremy’s picture

Issue tags: +7.x-1.4 blocker

This needs to be reviewed and if indeed page caching is broken, properly fixed. Tagging for next release.

wodenx’s picture

Jeremy’s picture

  • Jeremy committed a6a1ca8 on 7.x-1.x
    Issue #2335727 by wodenx, Jeremy: Setting $cache->created with msec...
Jeremy’s picture

Status: Needs review » Fixed

I'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

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.