Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
7115108c
Commit
7115108c
authored
Jul 28, 2015
by
alexpott
Browse files
Issue
#2527126
by dawehner, Wim Leers, hass: Only send cache context/tags if frontend proxy exists
parent
09e63473
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/lib/Drupal/Core/EventSubscriber/FinishResponseSubscriber.php
View file @
7115108c
...
...
@@ -116,8 +116,10 @@ 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.
if
(
$response
instanceof
CacheableResponseInterface
)
{
// 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
()));
$response
->
headers
->
set
(
'X-Drupal-Cache-Contexts'
,
implode
(
' '
,
$this
->
cacheContextsManager
->
optimizeTokens
(
$response_cacheability
->
getCacheContexts
())));
...
...
core/modules/simpletest/src/WebTestBase.php
View file @
7115108c
...
...
@@ -742,6 +742,13 @@ protected function prepareSettings() {
'value'
=>
FALSE
,
'required'
=>
TRUE
,
];
// Send cacheability headers so tests can check their values.
$settings
[
'settings'
][
'send_cacheability_headers'
]
=
(
object
)
[
'value'
=>
TRUE
,
'required'
=>
TRUE
,
];
$this
->
writeSettings
(
$settings
);
// Allow for test-specific overrides.
$settings_testing_file
=
DRUPAL_ROOT
.
'/'
.
$this
->
originalSite
.
'/settings.testing.php'
;
...
...
sites/example.settings.local.php
View file @
7115108c
...
...
@@ -58,6 +58,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.
*
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment