diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 0e7c4fc..b53bbce 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -156,8 +156,8 @@ public function onRespond(FilterResponseEvent $event) { // Add headers necessary to specify whether the response should be cached by // proxies and/or the browser. - if ($is_cacheable && $this->config->get('cache.page.max_age') > 0) { - if (!$this->isCacheControlCustomized($response)) { + if ($is_cacheable && $max_age > 0) { + if (!$this->isCacheControlCustomized($response) || $response->isClientError()) { // Only add the default Cache-Control header if the controller did not // specify one on the response. $this->setResponseCacheable($response, $request, $max_age);