diff --git a/core/modules/page_cache/src/StackMiddleware/PageCache.php b/core/modules/page_cache/src/StackMiddleware/PageCache.php index 14f9df5..4a8c4c7 100644 --- a/core/modules/page_cache/src/StackMiddleware/PageCache.php +++ b/core/modules/page_cache/src/StackMiddleware/PageCache.php @@ -249,8 +249,14 @@ protected function fetch(Request $request, $type = self::MASTER_REQUEST, $catch // interface, but see https://www.drupal.org/node/2352009 about possibly // changing that. $tags = $response->getCacheableMetadata()->getCacheTags(); - $date = $response->getExpires()->getTimestamp(); - $expire = ($date > time()) ? $date : Cache::PERMANENT; + $max_age = $response->getCacheableMetadata()->getCacheMaxAge(); + if ($max_age) { + $expire = time() + $max_age; + } + else { + $date = $response->getExpires()->getTimestamp(); + $expire = ($date > time()) ? $date : Cache::PERMANENT; + } $this->set($request, $response, $expire, $tags); // Mark response as a cache miss.