diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 759ec91..2af47c3 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -82,29 +82,29 @@ public function onRespond(FilterResponseEvent $event) { $response->headers->set($name, $value, FALSE); } - // Currently it is not possible to cache some types of responses. Therefore - // exclude binary file responses (generated files, e.g. images with image - // styles) and streamed responses (files directly read from the disk). - // see: https://github.com/symfony/symfony/issues/9128#issuecomment-25088678 - $is_cacheable = drupal_page_is_cacheable() && !($response instanceof BinaryFileResponse) && !($response instanceof StreamedResponse); + $is_cacheable = drupal_page_is_cacheable(); // 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)) { $this->setResponseCacheable($response, $request); + + // Currently it is not possible to cache some types of responses. Therefore + // exclude binary file responses (generated files, e.g. images with image + // styles) and streamed responses (files directly read from the disk). + // see: https://github.com/symfony/symfony/issues/9128#issuecomment-25088678 + if ($this->config->get('cache.page.use_internal') && !($response instanceof BinaryFileResponse) && !($response instanceof StreamedResponse)) { + // Store the response in the internal page cache. + drupal_page_set_cache($response, $request); + $response->headers->set('X-Drupal-Cache', 'MISS'); + drupal_serve_page_from_cache($response, $request); + } } } else { $this->setResponseNotCacheable($response, $request); } - - // Store the response in the internal page cache. - if ($is_cacheable && $this->config->get('cache.page.use_internal')) { - drupal_page_set_cache($response, $request); - $response->headers->set('X-Drupal-Cache', 'MISS'); - drupal_serve_page_from_cache($response, $request); - } } /**