.../Drupal/Core/EventSubscriber/FinishResponseSubscriber.php | 6 +++--- core/modules/simpletest/src/WebTestBase.php | 3 +-- sites/example.settings.local.php | 12 +++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php index 3f22250..48b53bd 100644 --- a/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php @@ -116,9 +116,9 @@ public function onRespond(FilterResponseEvent $event) { $response->headers->set('X-Frame-Options', 'SAMEORIGIN', FALSE); // Expose the cache contexts and cache tags associated with this page in a - // X-Drupal-Cache-Contexts and X-Drupal-Cache-Tags header respectively. - // We just want to send the cacheability headers in case it is actually - // needed, so a reverse proxy is used, or when we want to debug its values. + // 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 ((Settings::get('reverse_proxy', FALSE) || Settings::get('send_cacheability_headers', FALSE)) && $response instanceof CacheableResponseInterface) { $response_cacheability = $response->getCacheableMetadata(); $response->headers->set('X-Drupal-Cache-Tags', implode(' ', $response_cacheability->getCacheTags())); diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index c053110..dad9dbf 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -743,8 +743,7 @@ protected function prepareSettings() { 'required' => TRUE, ]; - // Enable to send cacheability metadata headers for tests in order to check - // their values. + // Send cacheability headers so tests can check their values. $settings['settings']['send_cacheability_headers'] = (object) [ 'value' => TRUE, 'required' => TRUE, diff --git a/sites/example.settings.local.php b/sites/example.settings.local.php index 8abdb00..0711fb9 100644 --- a/sites/example.settings.local.php +++ b/sites/example.settings.local.php @@ -59,6 +59,13 @@ $settings['cache']['bins']['render'] = '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. @@ -76,8 +83,3 @@ * using these parameters in a request to rebuild.php. */ $settings['rebuild_access'] = TRUE; - -/** - * Send cacheablity metadata for debugging purposes. - */ -$settings['send_cacheability_headers'] = TRUE;