diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 82be021..19cdf98 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -81,6 +83,10 @@ 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); // Add headers necessary to specify whether the response should be cached by diff --git a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php index 8baa3f2..51ae9ce 100644 --- a/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/DownloadTest.php @@ -53,7 +53,7 @@ function testPublicFileTransfer() { /** * Test the private file transfer system. */ - public function testPrivateFileTransfer() { + public function testPrivateFileTransferWithoutPageCache() { $this->doPrivateFileTransferTest(); }