Skip to content
Snippets Groups Projects

Commit patch #155

Open Björn Brala requested to merge issue/drupal-2352009:2352009-pp-3-bubbling-of into 11.x
4 files
+ 37
1
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -16,6 +16,7 @@
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Drupal\Core\Cache\CacheBackendInterface;
/**
* Response subscriber to handle finished responses.
@@ -233,6 +234,12 @@ protected function setResponseCacheable(Response $response, Request $request) {
}
$max_age = $this->config->get('cache.page.max_age');
// Respect max-age of the cacheable metadata, allowing for precise control
// over when cached pages should expire and be rebuilt.
$response_max_age = $response->getCacheableMetadata()->getCacheMaxAge();
if ($response_max_age !== CacheBackendInterface::CACHE_PERMANENT && $max_age > $response_max_age) {
$max_age = $response_max_age;
}
$response->headers->set('Cache-Control', 'public, max-age=' . $max_age);
// In order to support HTTP cache-revalidation, ensure that there is a
Loading