function TestResponseController::testCacheContextsHeaders
Provides a render array response that has a large number of cache contexts.
Return value
array Render array.
1 string reference to 'TestResponseController::testCacheContextsHeaders'
- http_response_debug_cacheability_headers_test.routing.yml in core/
modules/ system/ tests/ modules/ http_response_debug_cacheability_headers_test/ http_response_debug_cacheability_headers_test.routing.yml - core/modules/system/tests/modules/http_response_debug_cacheability_headers_test/http_response_debug_cacheability_headers_test.routing.yml
File
-
core/
modules/ system/ tests/ modules/ http_response_debug_cacheability_headers_test/ src/ Controller/ TestResponseController.php, line 31
Class
- TestResponseController
- Provides responses for testing debug cacheability headers in HTTP responses.
Namespace
Drupal\http_response_debug_cacheability_headers_test\ControllerCode
public function testCacheContextsHeaders() : array {
// Create multiple cache contexts that add up to more than 8k bytes.
for ($i = 0; $i < 700; $i++) {
$contexts[] = 'url.query_args:' . str_pad("{$i}", 4, '0', STR_PAD_LEFT);
}
$contexts_length = strlen(implode(' ', $contexts));
return [
'#markup' => 'This is a test of a list of cache contexts debug headers that exceed ' . $contexts_length . ' bytes in total.',
'#cache' => [
'contexts' => $contexts,
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.