diff --git a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
index c6b49ab..3d7c1f5 100644
--- a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
+++ b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php
@@ -55,7 +55,17 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
         $request::setTrustedProxies($proxies);
       }
     }
-    return $this->httpKernel->handle($request, $type, $catch);
+
+    $response = $this->httpKernel->handle($request, $type, $catch);
+
+    // 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->settings->get('send_cacheability_headers', FALSE))) {
+      $response->headers->remove('X-Drupal-Cache-Tags');
+      $response->headers->remove('X-Drupal-Cache-Contexts');
+    }
+    return $response;
   }
 
 }
diff --git a/core/modules/page_cache/src/Tests/PageCacheTest.php b/core/modules/page_cache/src/Tests/PageCacheTest.php
index a2278e7..8c1a2d3 100644
--- a/core/modules/page_cache/src/Tests/PageCacheTest.php
+++ b/core/modules/page_cache/src/Tests/PageCacheTest.php
@@ -50,6 +50,10 @@ protected function setUp() {
    * persisted.
    */
   function testPageCacheTags() {
+    // Ensure that the sending out of the cache tags / contexts is independent
+    // from the page cache.
+    $this->setCacheHeaders(FALSE);
+
     $config = $this->config('system.performance');
     $config->set('cache.page.max_age', 300);
     $config->save();
diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php
index f5c90cf..658fe03 100644
--- a/core/modules/simpletest/src/WebTestBase.php
+++ b/core/modules/simpletest/src/WebTestBase.php
@@ -812,6 +812,8 @@ 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->setCacheHeaders();
   }
 
   /**
@@ -3002,4 +3004,20 @@ protected function assertNoCacheTag($cache_tag) {
     $this->assertFalse(in_array($cache_tag, $cache_tags), "'" . $cache_tag . "' is absent in the X-Drupal-Cache-Tags header.");
   }
 
+  /**
+   * Sets the setting whether to send cacheability headers.
+   *
+   * @param bool $value
+   *   (optional) Should the cache headers be send.
+   */
+  protected function setCacheHeaders($value = TRUE) {
+    // Send cacheability headers so tests can check their values.
+    $settings['settings']['send_cacheability_headers'] = (object) [
+      'value' => TRUE,
+      'required' => TRUE,
+    ];
+
+    $this->writeSettings($settings);
+  }
+
 }
diff --git a/sites/example.settings.local.php b/sites/example.settings.local.php
index a5d50f2..dacc687 100644
--- a/sites/example.settings.local.php
+++ b/sites/example.settings.local.php
@@ -73,6 +73,13 @@
 # $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
 
 /**
+ * Send cacheablity headers for debugging purposes.
+ *
+ * By default, cacheability headers are only sent when behind a reverse proxy.
+ */
+# $settings['send_cacheability_headers'] = TRUE;
+
+/**
  * Allow test modules and themes to be installed.
  *
  * Drupal ignores test modules and themes by default for performance reasons.
