diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 759ec91..7a98950 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -82,11 +82,7 @@ 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. @@ -99,8 +95,12 @@ public function onRespond(FilterResponseEvent $event) { $this->setResponseNotCacheable($response, $request); } - // Store the response in the internal page cache. - if ($is_cacheable && $this->config->get('cache.page.use_internal')) { + // 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 ($is_cacheable && $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); diff --git a/core/modules/image/src/Controller/ImageStyleDownloadController.php b/core/modules/image/src/Controller/ImageStyleDownloadController.php index 191a6c7..bf4f9d9 100644 --- a/core/modules/image/src/Controller/ImageStyleDownloadController.php +++ b/core/modules/image/src/Controller/ImageStyleDownloadController.php @@ -143,6 +143,7 @@ public function deliver(Request $request, $scheme, ImageStyleInterface $image_st } if ($success) { + drupal_page_is_cacheable(FALSE); $image = $this->imageFactory->get($derivative_uri); $uri = $image->getSource(); $headers += array(