diff --git a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php index c6b49ab..8ef248e 100644 --- a/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php +++ b/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php @@ -55,7 +55,16 @@ 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'); + } } } diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 4418bd4..8c88f40 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -761,7 +761,7 @@ protected function prepareSettings() { 'value' => FALSE, 'required' => TRUE, ]; - + $this->writeSettings($settings); // Allow for test-specific overrides. $settings_testing_file = DRUPAL_ROOT . '/' . $this->originalSite . '/settings.testing.php'; 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.