diff --git a/core/core.services.yml b/core/core.services.yml
index 560036d..1d517cb 100644
--- a/core/core.services.yml
+++ b/core/core.services.yml
@@ -639,7 +639,7 @@ services:
       - { name: http_middleware, priority: 400 }
   http_middleware.reverse_proxy:
     class: Drupal\Core\StackMiddleware\ReverseProxyMiddleware
-    arguments: ['@settings', '%http.cacheability_headers.send%']
+    arguments: ['@settings']
     tags:
       - { name: http_middleware, priority: 300 }
   http_middleware.kernel_pre_handle:
@@ -1071,7 +1071,7 @@ services:
     class: Drupal\Core\EventSubscriber\FinishResponseSubscriber
     tags:
       - { name: event_subscriber }
-    arguments: ['@language_manager', '@config.factory', '@page_cache_request_policy', '@page_cache_response_policy', '@cache_contexts_manager']
+    arguments: ['@language_manager', '@config.factory', '@page_cache_request_policy', '@page_cache_response_policy', '@cache_contexts_manager', '%http.cacheability_headers.send%']
   response_generator_subscriber:
     class: Drupal\Core\EventSubscriber\ResponseGeneratorSubscriber
     tags:
diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
index b625f59..a76c00a 100644
--- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
@@ -62,6 +62,13 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
   protected $cacheContexts;
 
   /**
+   * Whether to send cacheability headers.
+   *
+   * @var bool
+   */
+  protected $httpCacheabilityHeadersSend = FALSE;
+
+  /**
    * Constructs a FinishResponseSubscriber object.
    *
    * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
@@ -74,13 +81,16 @@ class FinishResponseSubscriber implements EventSubscriberInterface {
    *   A policy rule determining the cacheability of a response.
    * @param \Drupal\Core\Cache\Context\CacheContextsManager $cache_contexts_manager
    *   The cache contexts manager service.
+   * @param bool $http_cacheability_headers_send
+   *   (optional) Whether to send cacheability headers.
    */
-  public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RequestPolicyInterface $request_policy, ResponsePolicyInterface $response_policy, CacheContextsManager $cache_contexts_manager) {
+  public function __construct(LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, RequestPolicyInterface $request_policy, ResponsePolicyInterface $response_policy, CacheContextsManager $cache_contexts_manager, $http_cacheability_headers_send = FALSE) {
     $this->languageManager = $language_manager;
     $this->config = $config_factory->get('system.performance');
     $this->requestPolicy = $request_policy;
     $this->responsePolicy = $response_policy;
     $this->cacheContextsManager = $cache_contexts_manager;
+    $this->httpCacheabilityHeadersSend = $http_cacheability_headers_send;
   }
 
   /**
@@ -130,11 +140,13 @@ public function onRespond(FilterResponseEvent $event) {
       return;
     }
 
-    // Expose the cache contexts and cache tags associated with this page in a
-    // X-Drupal-Cache-Contexts and X-Drupal-Cache-Tags header respectively.
-    $response_cacheability = $response->getCacheableMetadata();
-    $response->headers->set('X-Drupal-Cache-Tags', implode(' ', $response_cacheability->getCacheTags()));
-    $response->headers->set('X-Drupal-Cache-Contexts', implode(' ', $this->cacheContextsManager->optimizeTokens($response_cacheability->getCacheContexts())));
+    if ($this->httpCacheabilityHeadersSend) {
+      // Expose the cache contexts and cache tags associated with this page in a
+      // X-Drupal-Cache-Contexts and X-Drupal-Cache-Tags header respectively.
+      $response_cacheability = $response->getCacheableMetadata();
+      $response->headers->set('X-Drupal-Cache-Tags', implode(' ', $response_cacheability->getCacheTags()));
+      $response->headers->set('X-Drupal-Cache-Contexts', implode(' ', $this->cacheContextsManager->optimizeTokens($response_cacheability->getCacheContexts())));
+    }
 
     $is_cacheable = ($this->requestPolicy->check($request) === RequestPolicyInterface::ALLOW) && ($this->responsePolicy->check($response, $request) !== ResponsePolicyInterface::DENY);
 
diff --git a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
index 4291a5b..c6b49ab 100644
--- a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
+++ b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
@@ -30,26 +30,16 @@ class ReverseProxyMiddleware implements HttpKernelInterface {
   protected $settings;
 
   /**
-   * Whether to send cacheability headers.
-   *
-   * @var bool
-   */
-  protected $httpCacheabilityHeadersSend = FALSE;
-
-  /**
    * Constructs a ReverseProxyMiddleware object.
    *
    * @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel
    *   The decorated kernel.
    * @param \Drupal\Core\Site\Settings $settings
    *   The site settings.
-   * @param bool $http_cacheability_headers_send
-   *   (optional) Whether to send cacheability headers.
    */
-  public function __construct(HttpKernelInterface $http_kernel, Settings $settings, $http_cacheability_headers_send = FALSE) {
+  public function __construct(HttpKernelInterface $http_kernel, Settings $settings) {
     $this->httpKernel = $http_kernel;
     $this->settings = $settings;
-    $this->httpCacheabilityHeadersSend = $http_cacheability_headers_send;
   }
 
   /**
@@ -65,18 +55,7 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
         $request::setTrustedProxies($proxies);
       }
     }
-
-    $response = $this->httpKernel->handle($request, $type, $catch);
-
-    // Strip X-Drupal-Cache-Contexts and X-Drupal-Cache-Tags header
-    // respectively, when either a reverse proxy is being used (so the reverse
-    // proxy or CDN can be invalidated when appropriate) or when
-    // developing/debugging.
-    if (!($this->settings->get('reverse_proxy', FALSE) || $this->httpCacheabilityHeadersSend)) {
-      $response->headers->remove('X-Drupal-Cache-Tags');
-      $response->headers->remove('X-Drupal-Cache-Contexts');
-    }
-    return $response;
+    return $this->httpKernel->handle($request, $type, $catch);
   }
 
 }
diff --git a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
index 63a7e97..b3dc6d3 100644
--- a/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
+++ b/core/modules/aggregator/src/Tests/AggregatorRenderingTest.php
@@ -26,6 +26,9 @@ class AggregatorRenderingTest extends AggregatorTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalPlaceBlock('page_title_block');
   }
 
diff --git a/core/modules/block/src/Tests/BlockInstallTest.php b/core/modules/block/src/Tests/BlockInstallTest.php
index 84819e6..6d50133 100644
--- a/core/modules/block/src/Tests/BlockInstallTest.php
+++ b/core/modules/block/src/Tests/BlockInstallTest.php
@@ -17,6 +17,9 @@
 class BlockInstallTest extends WebTestBase {
 
   public function testCacheTagInvalidationUponInstallation() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Warm the page cache.
     $this->drupalGet('');
     $this->assertNoText('Powered by Drupal');
diff --git a/core/modules/block/src/Tests/BlockSystemBrandingTest.php b/core/modules/block/src/Tests/BlockSystemBrandingTest.php
index a78f675..89b328d 100644
--- a/core/modules/block/src/Tests/BlockSystemBrandingTest.php
+++ b/core/modules/block/src/Tests/BlockSystemBrandingTest.php
@@ -32,6 +32,9 @@ protected function setUp() {
       ->save();
     // Add the system branding block to the page.
     $this->drupalPlaceBlock('system_branding_block', array('region' => 'header', 'id' => 'site-branding'));
+
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
   }
 
   /**
diff --git a/core/modules/block/src/Tests/Views/DisplayBlockTest.php b/core/modules/block/src/Tests/Views/DisplayBlockTest.php
index f7b3ffe..762af23 100644
--- a/core/modules/block/src/Tests/Views/DisplayBlockTest.php
+++ b/core/modules/block/src/Tests/Views/DisplayBlockTest.php
@@ -241,6 +241,9 @@ public function testViewsBlockForm() {
    * Tests the actual rendering of the views block.
    */
   public function testBlockRendering() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Create a block and set a custom title.
     $block = $this->drupalPlaceBlock('views_block:test_view_block-block_1', array('label' => 'test_view_block-block_1:1', 'views_label' => 'Custom title'));
     $this->drupalGet('');
@@ -272,6 +275,9 @@ public function testBlockRendering() {
    * Tests the various testcases of empty block rendering.
    */
   public function testBlockEmptyRendering() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $url = new Url('test_page_test.test_page');
     // Remove all views_test_data entries.
     \Drupal::database()->truncate('views_test_data')->execute();
diff --git a/core/modules/book/src/Tests/BookTest.php b/core/modules/book/src/Tests/BookTest.php
index b1c9fa3..4d5a7f4 100644
--- a/core/modules/book/src/Tests/BookTest.php
+++ b/core/modules/book/src/Tests/BookTest.php
@@ -170,6 +170,9 @@ function testEmptyBook() {
    * Tests book functionality through node interfaces.
    */
   function testBook() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Create new book.
     $nodes = $this->createBook();
     $book = $this->book;
diff --git a/core/modules/comment/src/Tests/CommentAnonymousTest.php b/core/modules/comment/src/Tests/CommentAnonymousTest.php
index b7e5bd8..e374a43 100644
--- a/core/modules/comment/src/Tests/CommentAnonymousTest.php
+++ b/core/modules/comment/src/Tests/CommentAnonymousTest.php
@@ -19,6 +19,9 @@ class CommentAnonymousTest extends CommentTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Enable anonymous and authenticated user comments.
     user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array(
       'access comments',
diff --git a/core/modules/comment/src/Tests/CommentRssTest.php b/core/modules/comment/src/Tests/CommentRssTest.php
index 2a87859..47d587a 100644
--- a/core/modules/comment/src/Tests/CommentRssTest.php
+++ b/core/modules/comment/src/Tests/CommentRssTest.php
@@ -34,6 +34,9 @@ class CommentRssTest extends CommentTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Setup the rss view display.
     EntityViewDisplay::create([
       'status' => TRUE,
diff --git a/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideIntegrationTest.php b/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideIntegrationTest.php
index 22d0b11..d5ec698 100644
--- a/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideIntegrationTest.php
+++ b/core/modules/config/src/Tests/CacheabilityMetadataConfigOverrideIntegrationTest.php
@@ -30,6 +30,9 @@ class CacheabilityMetadataConfigOverrideIntegrationTest extends WebTestBase {
   public function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // @todo If our block does not contain any content then the cache context
     //   is not bubbling up and the test fails. Remove this line once the cache
     //   contexts are properly set. See https://www.drupal.org/node/2529980.
diff --git a/core/modules/contact/src/Tests/ContactPersonalTest.php b/core/modules/contact/src/Tests/ContactPersonalTest.php
index d133240..6f923e0 100644
--- a/core/modules/contact/src/Tests/ContactPersonalTest.php
+++ b/core/modules/contact/src/Tests/ContactPersonalTest.php
@@ -109,6 +109,9 @@ function testSendPersonalContactMessage() {
    * Tests access to the personal contact form.
    */
   function testPersonalContactAccess() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Test allowed access to admin user's contact form.
     $this->drupalLogin($this->webUser);
     $this->drupalGet('user/' . $this->adminUser->id() . '/contact');
diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/src/Tests/ContactSitewideTest.php
index 39cd34a..67c0d78 100644
--- a/core/modules/contact/src/Tests/ContactSitewideTest.php
+++ b/core/modules/contact/src/Tests/ContactSitewideTest.php
@@ -47,6 +47,9 @@ protected function setUp() {
    * Tests configuration options and the site-wide contact form.
    */
   function testSiteWideContact() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Create and login administrative user.
     $admin_user = $this->drupalCreateUser(array(
       'access site-wide contact form',
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php
index 9ed2e46..5c8fa6a 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationUITestBase.php
@@ -58,6 +58,9 @@
    * Tests the basic translation UI.
    */
   function testTranslationUI() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->doTestBasicTranslation();
     $this->doTestTranslationOverview();
     $this->doTestOutdatedStatus();
diff --git a/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php b/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php
index b602be0..18555a3 100644
--- a/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php
+++ b/core/modules/content_translation/src/Tests/ContentTranslationWorkflowsTest.php
@@ -36,6 +36,8 @@ class ContentTranslationWorkflowsTest extends ContentTranslationTestBase {
   protected function setUp() {
     parent::setUp();
     $this->setupEntity();
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
   }
 
   /**
diff --git a/core/modules/forum/src/Tests/ForumIndexTest.php b/core/modules/forum/src/Tests/ForumIndexTest.php
index e84a3eb..3dc90f4 100644
--- a/core/modules/forum/src/Tests/ForumIndexTest.php
+++ b/core/modules/forum/src/Tests/ForumIndexTest.php
@@ -29,6 +29,9 @@ protected function setUp() {
     // Create a test user.
     $web_user = $this->drupalCreateUser(['create forum content', 'edit own forum content', 'edit any forum content', 'administer nodes', 'administer forums']);
     $this->drupalLogin($web_user);
+
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
   }
 
   /**
diff --git a/core/modules/forum/src/Tests/ForumTest.php b/core/modules/forum/src/Tests/ForumTest.php
index 974e400..638fa85 100644
--- a/core/modules/forum/src/Tests/ForumTest.php
+++ b/core/modules/forum/src/Tests/ForumTest.php
@@ -123,6 +123,9 @@ protected function setUp() {
    * Tests forum functionality through the admin and user interfaces.
    */
   function testForum() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     //Check that the basic forum install creates a default forum topic
     $this->drupalGet('/forum');
     // Look for the "General discussion" default forum
diff --git a/core/modules/history/src/Tests/HistoryTest.php b/core/modules/history/src/Tests/HistoryTest.php
index 3340f1a..ecab8b7 100644
--- a/core/modules/history/src/Tests/HistoryTest.php
+++ b/core/modules/history/src/Tests/HistoryTest.php
@@ -41,6 +41,9 @@ class HistoryTest extends WebTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
 
     $this->user = $this->drupalCreateUser(array('create page content', 'access content'));
diff --git a/core/modules/image/src/Tests/ImageFieldDisplayTest.php b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
index c4cf485..0a40d1a 100644
--- a/core/modules/image/src/Tests/ImageFieldDisplayTest.php
+++ b/core/modules/image/src/Tests/ImageFieldDisplayTest.php
@@ -32,6 +32,9 @@ class ImageFieldDisplayTest extends ImageFieldTestBase {
    * Test image formatters on node display for public files.
    */
   function testImageFieldFormattersPublic() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->_testImageFieldFormatters('public');
   }
 
@@ -39,6 +42,9 @@ function testImageFieldFormattersPublic() {
    * Test image formatters on node display for private files.
    */
   function testImageFieldFormattersPrivate() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Remove access content permission from anonymous users.
     user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array('access content' => FALSE));
     $this->_testImageFieldFormatters('private');
@@ -323,6 +329,9 @@ function testImageFieldSettings() {
    * Test use of a default image with an image field.
    */
   function testImageFieldDefaultImage() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     /** @var \Drupal\Core\Render\RendererInterface $renderer */
     $renderer = $this->container->get('renderer');
 
diff --git a/core/modules/menu_ui/src/Tests/MenuNodeTest.php b/core/modules/menu_ui/src/Tests/MenuNodeTest.php
index b3397cc..bf11c0b 100644
--- a/core/modules/menu_ui/src/Tests/MenuNodeTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuNodeTest.php
@@ -34,6 +34,9 @@ class MenuNodeTest extends WebTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalPlaceBlock('system_menu_block:main');
     $this->drupalPlaceBlock('page_title_block');
 
diff --git a/core/modules/menu_ui/src/Tests/MenuTest.php b/core/modules/menu_ui/src/Tests/MenuTest.php
index f8c26c9..095e282 100644
--- a/core/modules/menu_ui/src/Tests/MenuTest.php
+++ b/core/modules/menu_ui/src/Tests/MenuTest.php
@@ -543,6 +543,9 @@ function testSystemMenuRename() {
    * Tests that menu items pointing to unpublished nodes are editable.
    */
   function testUnpublishedNodeMenuItem() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer blocks', 'administer menu', 'create article content', 'bypass node access')));
     // Create an unpublished node.
     $node = $this->drupalCreateNode(array(
diff --git a/core/modules/node/src/Tests/NodeBlockFunctionalTest.php b/core/modules/node/src/Tests/NodeBlockFunctionalTest.php
index 386188f..649a77d 100644
--- a/core/modules/node/src/Tests/NodeBlockFunctionalTest.php
+++ b/core/modules/node/src/Tests/NodeBlockFunctionalTest.php
@@ -45,6 +45,9 @@ class NodeBlockFunctionalTest extends NodeTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Create users and test node.
     $this->adminUser = $this->drupalCreateUser(array('administer content types', 'administer nodes', 'administer blocks', 'access content overview'));
     $this->webUser = $this->drupalCreateUser(array('access content', 'create article content'));
diff --git a/core/modules/node/src/Tests/NodeTypeTest.php b/core/modules/node/src/Tests/NodeTypeTest.php
index a8fa54d..7876b5c 100644
--- a/core/modules/node/src/Tests/NodeTypeTest.php
+++ b/core/modules/node/src/Tests/NodeTypeTest.php
@@ -89,6 +89,9 @@ function testNodeTypeCreation() {
    * Tests editing a node type using the UI.
    */
   function testNodeTypeEditing() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $web_user = $this->drupalCreateUser(array('bypass node access', 'administer content types', 'administer node fields'));
     $this->drupalLogin($web_user);
 
diff --git a/core/modules/node/src/Tests/Views/FrontPageTest.php b/core/modules/node/src/Tests/Views/FrontPageTest.php
index 5cd78a8..6201446 100644
--- a/core/modules/node/src/Tests/Views/FrontPageTest.php
+++ b/core/modules/node/src/Tests/Views/FrontPageTest.php
@@ -47,6 +47,9 @@ class FrontPageTest extends ViewTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->nodeStorage = $this->container->get('entity.manager')
       ->getStorage('node');
   }
diff --git a/core/modules/page_cache/src/StackMiddleware/PageCache.php b/core/modules/page_cache/src/StackMiddleware/PageCache.php
index 23ddb84..85a7275 100644
--- a/core/modules/page_cache/src/StackMiddleware/PageCache.php
+++ b/core/modules/page_cache/src/StackMiddleware/PageCache.php
@@ -8,6 +8,7 @@
 namespace Drupal\page_cache\StackMiddleware;
 
 use Drupal\Core\Cache\Cache;
+use Drupal\Core\Cache\CacheableResponseInterface;
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\PageCache\RequestPolicyInterface;
 use Drupal\Core\PageCache\ResponsePolicyInterface;
@@ -224,7 +225,7 @@ protected function fetch(Request $request, $type = self::MASTER_REQUEST, $catch
     $date = $response->getExpires()->getTimestamp();
     $expire = ($date > time()) ? $date : Cache::PERMANENT;
 
-    $tags = explode(' ', $response->headers->get('X-Drupal-Cache-Tags'));
+    $tags = ($response instanceof CacheableResponseInterface) ? $response->getCacheableMetadata()->getCacheTags() : [];
     $this->set($request, $response, $expire, $tags);
 
     // Mark response as a cache miss.
diff --git a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
index 22ae7b2..16e782d 100644
--- a/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
+++ b/core/modules/page_cache/src/Tests/PageCacheTagsIntegrationTest.php
@@ -33,6 +33,9 @@ class PageCacheTagsIntegrationTest extends WebTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->enablePageCaching();
   }
 
diff --git a/core/modules/page_cache/src/Tests/PageCacheTest.php b/core/modules/page_cache/src/Tests/PageCacheTest.php
index 3e89ffe..3ab7fcd 100644
--- a/core/modules/page_cache/src/Tests/PageCacheTest.php
+++ b/core/modules/page_cache/src/Tests/PageCacheTest.php
@@ -50,10 +50,6 @@ protected function setUp() {
    * persisted.
    */
   function testPageCacheTags() {
-    // Ensure that the sending out of the cache tags / contexts is independent
-    // from the page cache.
-    $this->setCacheabilityHeaders(FALSE);
-
     $config = $this->config('system.performance');
     $config->set('cache.page.max_age', 300);
     $config->save();
@@ -261,6 +257,9 @@ function testPageCache() {
    * roles.
    */
   public function testPageCacheAnonymousRolePermissions() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $config = $this->config('system.performance');
     $config->set('cache.page.max_age', 300);
     $config->save();
@@ -313,6 +312,9 @@ public function testPageCacheAnonymousRolePermissions() {
    * Tests the 4xx-response cache tag is added and invalidated.
    */
   function testPageCacheAnonymous403404() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $admin_url = Url::fromRoute('system.admin');
     $invalid_url = 'foo/does_not_exist';
     $tests = [
diff --git a/core/modules/rest/src/Tests/PageCacheTest.php b/core/modules/rest/src/Tests/PageCacheTest.php
index 3ae0084..0daad28 100644
--- a/core/modules/rest/src/Tests/PageCacheTest.php
+++ b/core/modules/rest/src/Tests/PageCacheTest.php
@@ -25,6 +25,9 @@ class PageCacheTest extends RESTTestBase {
    * Tests that configuration changes also clear the page cache.
    */
   public function testConfigChangePageCache() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->enableService('entity:entity_test', 'GET');
     // Allow anonymous users to issue GET requests.
     $permissions = $this->entityPermissions('entity_test', 'view');
diff --git a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
index 5f378ee..c127fd9 100644
--- a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
+++ b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php
@@ -76,6 +76,9 @@ protected function setUp() {
    * Checks the behavior of the Serializer callback paths and row plugins.
    */
   public function testSerializerResponses() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Test the serialize callback.
     $view = Views::getView('test_serializer_display_field');
     $view->initDisplay();
@@ -204,6 +207,9 @@ protected function addRequestWithFormat($format) {
    * Tests REST export with views render caching enabled.
    */
   public function testRestRenderCaching() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalLogin($this->adminUser);
     /** @var \Drupal\Core\Render\RenderCacheInterface $render_cache */
     $render_cache = \Drupal::service('render_cache');
diff --git a/core/modules/search/src/Tests/SearchPageCacheTagsTest.php b/core/modules/search/src/Tests/SearchPageCacheTagsTest.php
index 6a74718..75d4e0e 100644
--- a/core/modules/search/src/Tests/SearchPageCacheTagsTest.php
+++ b/core/modules/search/src/Tests/SearchPageCacheTagsTest.php
@@ -41,6 +41,9 @@ class SearchPageCacheTagsTest extends SearchTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Create user.
     $this->searchingUser = $this->drupalCreateUser(array('search content', 'access user profiles'));
 
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index 705e287..00ab639 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -812,8 +812,6 @@ protected function initSettings() {
     // TestBase::restoreEnvironment() will delete the entire site directory.
     // Not using File API; a potential error must trigger a PHP warning.
     chmod(DRUPAL_ROOT . '/' . $this->siteDirectory, 0777);
-
-    $this->setCacheabilityHeaders();
   }
 
   /**
diff --git a/core/modules/system/src/Tests/Common/EarlyRenderingControllerTest.php b/core/modules/system/src/Tests/Common/EarlyRenderingControllerTest.php
index b3b363a..4105e0a 100644
--- a/core/modules/system/src/Tests/Common/EarlyRenderingControllerTest.php
+++ b/core/modules/system/src/Tests/Common/EarlyRenderingControllerTest.php
@@ -32,6 +32,9 @@ class EarlyRenderingControllerTest extends WebTestBase {
    * Tests theme preprocess functions being able to attach assets.
    */
   function testEarlyRendering() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Render array: non-early & early.
     $this->drupalGet(Url::fromRoute('early_rendering_controller_test.render_array'));
     $this->assertResponse(200);
diff --git a/core/modules/system/src/Tests/Common/RenderWebTest.php b/core/modules/system/src/Tests/Common/RenderWebTest.php
index 4f11071..3f0cc43 100644
--- a/core/modules/system/src/Tests/Common/RenderWebTest.php
+++ b/core/modules/system/src/Tests/Common/RenderWebTest.php
@@ -30,6 +30,9 @@ class RenderWebTest extends WebTestBase {
    * Asserts the cache context for the wrapper format is always present.
    */
   function testWrapperFormatCacheContext() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalGet('common-test/type-link-active-class');
     $this->assertIdentical(0, strpos($this->getRawContent(), "<!DOCTYPE html>\n<html"));
     $this->assertIdentical('text/html; charset=UTF-8', $this->drupalGetHeader('Content-Type'));
diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
index dd35bbd..77d47b8 100644
--- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
+++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php
@@ -58,6 +58,9 @@
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Give anonymous users permission to view test entities, so that we can
     // verify the cache tags of cached versions of test entity pages.
     $user_role = Role::load(RoleInterface::ANONYMOUS_ID);
diff --git a/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php b/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php
index f38c62d..4a05753 100644
--- a/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php
+++ b/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php
@@ -74,6 +74,9 @@ public function testCacheContexts() {
    * Tests if the list cache tags are set.
    */
   public function testCacheTags() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalGet('entity_test/list');
     $this->assertCacheTag('entity_test_list');
   }
diff --git a/core/modules/system/src/Tests/Menu/LocalTasksTest.php b/core/modules/system/src/Tests/Menu/LocalTasksTest.php
index 015f4de..aef0614 100644
--- a/core/modules/system/src/Tests/Menu/LocalTasksTest.php
+++ b/core/modules/system/src/Tests/Menu/LocalTasksTest.php
@@ -104,6 +104,9 @@ protected function assertNoLocalTasks($level = 0) {
    * Tests the plugin based local tasks.
    */
   public function testPluginLocalTask() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Verify local tasks defined in the hook.
     $this->drupalGet(Url::fromRoute('menu_test.tasks_default'));
     $this->assertLocalTasks([
diff --git a/core/modules/system/src/Tests/Pager/PagerTest.php b/core/modules/system/src/Tests/Pager/PagerTest.php
index 4d7e0a1..317dd19 100644
--- a/core/modules/system/src/Tests/Pager/PagerTest.php
+++ b/core/modules/system/src/Tests/Pager/PagerTest.php
@@ -73,6 +73,9 @@ function testActiveClass() {
    * Test proper functioning of the query parameters and the pager cache context.
    */
   protected function testPagerQueryParametersAndCacheContext() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // First page.
     $this->drupalGet('pager-test/query-parameters');
     $this->assertText(t('Pager calls: 0'), 'Initial call to pager shows 0 calls.');
diff --git a/core/modules/system/src/Tests/Render/DisplayVariantTest.php b/core/modules/system/src/Tests/Render/DisplayVariantTest.php
index c4c37bb..064582b 100644
--- a/core/modules/system/src/Tests/Render/DisplayVariantTest.php
+++ b/core/modules/system/src/Tests/Render/DisplayVariantTest.php
@@ -27,6 +27,9 @@ class DisplayVariantTest extends WebTestBase {
    * Tests selecting the variant and passing configuration.
    */
   function testPageDisplayVariantSelectionEvent() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Tests that our display variant was selected, and that its configuration
     // was passed correctly. If the configuration wasn't passed, we'd get an
     // error page here.
diff --git a/core/modules/system/src/Tests/Render/UrlBubbleableMetadataBubblingTest.php b/core/modules/system/src/Tests/Render/UrlBubbleableMetadataBubblingTest.php
index 2ae068e..a185ba3 100644
--- a/core/modules/system/src/Tests/Render/UrlBubbleableMetadataBubblingTest.php
+++ b/core/modules/system/src/Tests/Render/UrlBubbleableMetadataBubblingTest.php
@@ -30,6 +30,9 @@ class UrlBubbleableMetadataBubblingTest extends WebTestBase {
   protected function setUp() {
     parent::setUp();
     $this->dumpHeaders = TRUE;
+
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
   }
 
   /**
diff --git a/core/modules/system/src/Tests/System/TokenReplaceWebTest.php b/core/modules/system/src/Tests/System/TokenReplaceWebTest.php
index ba94e51..b2b23b9 100644
--- a/core/modules/system/src/Tests/System/TokenReplaceWebTest.php
+++ b/core/modules/system/src/Tests/System/TokenReplaceWebTest.php
@@ -29,6 +29,9 @@ class TokenReplaceWebTest extends WebTestBase {
    * Tests a token replacement on an actual website.
    */
   public function testTokens() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $node = $this->drupalCreateNode();
     $account = $this->drupalCreateUser();
     $this->drupalLogin($account);
diff --git a/core/modules/system/src/Tests/Theme/EngineTwigTest.php b/core/modules/system/src/Tests/Theme/EngineTwigTest.php
index 283b41d..cba633f 100644
--- a/core/modules/system/src/Tests/Theme/EngineTwigTest.php
+++ b/core/modules/system/src/Tests/Theme/EngineTwigTest.php
@@ -46,6 +46,9 @@ function testTwigVariableDataTypes() {
    * Tests the url and url_generate Twig functions.
    */
   public function testTwigUrlGenerator() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalGet('twig-theme-test/url-generator');
     // Find the absolute URL of the current site.
     $url_generator = $this->container->get('url_generator');
@@ -75,6 +78,9 @@ public function testTwigUrlGenerator() {
    * Tests the link_generator Twig functions.
    */
   public function testTwigLinkGenerator() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalGet('twig-theme-test/link-generator');
 
      /** @var \Drupal\Core\Utility\LinkGenerator $link_generator */
diff --git a/core/modules/toolbar/src/Tests/ToolbarCacheContextsTest.php b/core/modules/toolbar/src/Tests/ToolbarCacheContextsTest.php
index 759f646..a4d2cb6 100644
--- a/core/modules/toolbar/src/Tests/ToolbarCacheContextsTest.php
+++ b/core/modules/toolbar/src/Tests/ToolbarCacheContextsTest.php
@@ -60,6 +60,9 @@ class ToolbarCacheContextsTest extends WebTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->adminUser = $this->drupalCreateUser($this->perms);
     $this->adminUser2 = $this->drupalCreateUser($this->perms);
   }
diff --git a/core/modules/tracker/src/Tests/TrackerTest.php b/core/modules/tracker/src/Tests/TrackerTest.php
index 425c4a1..6979704 100644
--- a/core/modules/tracker/src/Tests/TrackerTest.php
+++ b/core/modules/tracker/src/Tests/TrackerTest.php
@@ -69,6 +69,9 @@ protected function setUp() {
    * Tests for the presence of nodes on the global tracker listing.
    */
   function testTrackerAll() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalLogin($this->user);
 
     $unpublished = $this->drupalCreateNode(array(
@@ -135,6 +138,9 @@ function testTrackerAll() {
    * Tests for the presence of nodes on a user's tracker listing.
    */
   function testTrackerUser() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalLogin($this->user);
 
     $unpublished = $this->drupalCreateNode(array(
diff --git a/core/modules/user/src/Tests/UserLoginTest.php b/core/modules/user/src/Tests/UserLoginTest.php
index 39ffed5..3e644a1 100644
--- a/core/modules/user/src/Tests/UserLoginTest.php
+++ b/core/modules/user/src/Tests/UserLoginTest.php
@@ -21,6 +21,9 @@ class UserLoginTest extends WebTestBase {
    * Tests login with destination.
    */
   function testLoginCacheTagsAndDestination() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalGet('user/login');
     // The user login form says "Enter your <site name> username.", hence it
     // depends on config:system.site, and its cache tags should be present.
diff --git a/core/modules/user/src/Tests/UserRegistrationTest.php b/core/modules/user/src/Tests/UserRegistrationTest.php
index 1e16bc7..cfa325f 100644
--- a/core/modules/user/src/Tests/UserRegistrationTest.php
+++ b/core/modules/user/src/Tests/UserRegistrationTest.php
@@ -224,6 +224,9 @@ public function testUuidFormState() {
   }
 
   function testRegistrationDefaultValues() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Don't require email verification and allow registration by site visitors
     // without administrator approval.
     $config_user_settings = $this->config('user.settings')
@@ -287,6 +290,9 @@ public function testUniqueFields() {
    * Tests Field API fields on user registration forms.
    */
   function testRegistrationWithUserFields() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Create a field on 'user' entity type.
     $field_storage = entity_create('field_storage_config', array(
       'field_name' => 'test_user_field',
diff --git a/core/modules/user/src/Tests/Views/AccessRoleTest.php b/core/modules/user/src/Tests/Views/AccessRoleTest.php
index a6230b3..e66b909 100644
--- a/core/modules/user/src/Tests/Views/AccessRoleTest.php
+++ b/core/modules/user/src/Tests/Views/AccessRoleTest.php
@@ -31,6 +31,9 @@ class AccessRoleTest extends AccessTestBase {
    * Tests role access plugin.
    */
   function testAccessRole() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     /** @var \Drupal\views\ViewEntityInterface $view */
     $view = \Drupal::entityManager()->getStorage('view')->load('test_access_role');
     $display = &$view->getDisplay('default');
diff --git a/core/modules/views/src/Tests/GlossaryTest.php b/core/modules/views/src/Tests/GlossaryTest.php
index d79b183..4c99a39 100644
--- a/core/modules/views/src/Tests/GlossaryTest.php
+++ b/core/modules/views/src/Tests/GlossaryTest.php
@@ -32,6 +32,9 @@ class GlossaryTest extends ViewTestBase {
    * Tests the default glossary view.
    */
   public function testGlossaryView() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Create a content type and add some nodes, with a non-random title.
     $type = $this->drupalCreateContentType();
     $nodes_per_char = array(
diff --git a/core/modules/views/src/Tests/Handler/FieldWebTest.php b/core/modules/views/src/Tests/Handler/FieldWebTest.php
index ddc9b50..693efcf 100644
--- a/core/modules/views/src/Tests/Handler/FieldWebTest.php
+++ b/core/modules/views/src/Tests/Handler/FieldWebTest.php
@@ -65,6 +65,9 @@ protected function viewsData() {
    * Tests the click sorting functionality.
    */
   public function testClickSorting() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalGet('test_click_sort');
     $this->assertResponse(200);
 
diff --git a/core/modules/views/src/Tests/Plugin/CacheWebTest.php b/core/modules/views/src/Tests/Plugin/CacheWebTest.php
index 85194e2..2c80295 100644
--- a/core/modules/views/src/Tests/Plugin/CacheWebTest.php
+++ b/core/modules/views/src/Tests/Plugin/CacheWebTest.php
@@ -48,6 +48,9 @@ protected function setUp() {
    * Tests the output caching on an actual page.
    */
   public function testCacheOutputOnPage() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $view = Views::getView('test_display');
     $view->storage->setStatus(TRUE);
     $view->setDisplay('page_1');
diff --git a/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php b/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php
index 1ce4f59..e67936f 100644
--- a/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php
+++ b/core/modules/views/src/Tests/Plugin/DisplayPageWebTest.php
@@ -47,6 +47,9 @@ protected function setUp() {
    * Tests arguments.
    */
   public function testArguments() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->drupalGet('test_route_without_arguments');
     $this->assertResponse(200);
     $result = $this->xpath('//span[@class="field-content"]');
diff --git a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
index 8906cfd..1f2181e 100644
--- a/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
+++ b/core/modules/views/src/Tests/Plugin/ExposedFormTest.php
@@ -222,6 +222,9 @@ public function testTextInputRequired() {
    * Tests exposed forms with exposed sort and items per page.
    */
   public function testExposedSortAndItemsPerPage() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     for ($i = 0; $i < 50; $i++) {
       $entity = EntityTest::create([
       ]);
diff --git a/core/modules/views/src/Tests/Plugin/PagerTest.php b/core/modules/views/src/Tests/Plugin/PagerTest.php
index bdd95ed..f3c9fb6 100644
--- a/core/modules/views/src/Tests/Plugin/PagerTest.php
+++ b/core/modules/views/src/Tests/Plugin/PagerTest.php
@@ -209,6 +209,9 @@ public function testLimit() {
    * Tests the normal pager.
    */
   public function testNormalPager() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     // Create 11 nodes and make sure that everyone is returned.
     // We create 11 nodes, because the default pager plugin had 10 items per page.
     $this->drupalCreateContentType(array('type' => 'page'));
diff --git a/core/modules/views/src/Tests/RenderCacheIntegrationTest.php b/core/modules/views/src/Tests/RenderCacheIntegrationTest.php
index a5b7cad..8bd1b3d 100644
--- a/core/modules/views/src/Tests/RenderCacheIntegrationTest.php
+++ b/core/modules/views/src/Tests/RenderCacheIntegrationTest.php
@@ -39,6 +39,9 @@ class RenderCacheIntegrationTest extends ViewKernelTestBase {
   protected function setUp() {
     parent::setUp();
 
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->installEntitySchema('entity_test');
     $this->installEntitySchema('user');
   }
diff --git a/core/modules/views_ui/src/Tests/DisplayPathTest.php b/core/modules/views_ui/src/Tests/DisplayPathTest.php
index 5e8f595..f2188cf 100644
--- a/core/modules/views_ui/src/Tests/DisplayPathTest.php
+++ b/core/modules/views_ui/src/Tests/DisplayPathTest.php
@@ -121,6 +121,9 @@ public function testDeleteWithNoPath() {
    * Tests the menu and tab option form.
    */
   public function testMenuOptions() {
+    $this->setCacheabilityHeaders(TRUE);
+    $this->rebuildContainer();
+
     $this->container->get('module_installer')->install(array('menu_ui'));
     $this->drupalGet('admin/structure/views/view/test_view');
 
diff --git a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
index e65feb7..f92109b 100644
--- a/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
+++ b/core/tests/Drupal/Tests/Core/StackMiddleware/ReverseProxyMiddlewareTest.php
@@ -11,13 +11,10 @@
 use Drupal\Core\StackMiddleware\ReverseProxyMiddleware;
 use Drupal\Tests\UnitTestCase;
 use Symfony\Component\HttpFoundation\Request;
-use Symfony\Component\HttpFoundation\Response;
 
 /**
  * Unit test the reverse proxy stack middleware.
  *
- * @coversDefaultClass \Drupal\Core\StackMiddleware\ReverseProxyMiddleware
- *
  * @group StackMiddleware
  */
 class ReverseProxyMiddlewareTest extends UnitTestCase {
@@ -47,59 +44,8 @@ public function testNoProxy() {
     // setTrustedHeaderName() should never fire.
     $request->expects($this->never())
       ->method('setTrustedHeaderName');
-
-    $response = new Response();
-    $this->mockHttpKernel->expects($this->any())
-      ->method('handle')
-      ->willReturn($response);
-
     // Actually call the check method.
-    $result = $middleware->handle($request);
-    $this->assertEquals($response, $result);
-  }
-
-  /**
-   * @covers ::handle
-   */
-  public function testCacheabilityHeadersEnabled() {
-    $middleware = new ReverseProxyMiddleware($this->mockHttpKernel, new Settings([]), TRUE);
-
-    $request = new Request();
-
-    $response = new Response();
-    $response->headers->set('X-Drupal-Cache-Tags', 'node:123 node_list');
-    $response->headers->set('X-Drupal-Cache-Contexts', 'languages:language_interface route');
-
-    $this->mockHttpKernel->expects($this->any())
-      ->method('handle')
-      ->willReturn($response);
-
-    $result = $middleware->handle($request);
-    $this->assertEquals('node:123 node_list', $result->headers->get('X-Drupal-Cache-Tags'));
-    $this->assertEquals('languages:language_interface route', $result->headers->get('X-Drupal-Cache-Contexts'));
-  }
-
-  /**
-   * @covers ::handle
-   */
-  public function testCacheabilityHeadersDisabled() {
-    $settings = new Settings([]);
-
-    $middleware = new ReverseProxyMiddleware($this->mockHttpKernel, $settings, FALSE);
-
-    $request = new Request();
-
-    $response = new Response();
-    $response->headers->set('X-Drupal-Cache-Tags', 'node:123 node_list');
-    $response->headers->set('X-Drupal-Cache-Contexts', 'languages:language_interface route');
-
-    $this->mockHttpKernel->expects($this->any())
-      ->method('handle')
-      ->willReturn($response);
-
-    $result = $middleware->handle($request);
-    $this->assertFalse($result->headers->has('X-Drupal-Cache-Tags'));
-    $this->assertFalse($result->headers->has('X-Drupal-Cache-Contexts'));
+    $middleware->handle($request);
   }
 
   /**
diff --git a/sites/default/default.services.yml b/sites/default/default.services.yml
index 048aceb..c8d8dba 100644
--- a/sites/default/default.services.yml
+++ b/sites/default/default.services.yml
@@ -115,6 +115,9 @@ parameters:
       #
       # @default []
       tags: []
+  # Send cacheablity headers for debugging purposes.
+  # By default, cacheability headers are only sent when behind a reverse proxy.
+  http.cacheability_headers.send: false
   factory.keyvalue:
     {}
     # Default key/value storage service to use.
@@ -142,7 +145,3 @@ parameters:
     - sftp
     - webcal
     - rtsp
-
-  # Send cacheablity headers for debugging purposes.
-  # By default, cacheability headers are only sent when behind a reverse proxy.
-  # http.cacheability_headers.send: false
