function FinishResponseSubscriber::addDebugCacheHeaders
Adds cache metadata information as headers in the response.
If a header exceeds the maximum response header length, the data will be split across multiple header lines with the same header name. By default, Apache uses the header merge strategy that merges and glues all the lines into one with ', ' separating them. Nginx will send separate headers lines with the same name.
Parameters
string $header: The response header name.
list<string> $values: The list of either cache tags or contexts.
\Symfony\Component\HttpFoundation\Response $response: The response object.
File
-
core/
lib/ Drupal/ Core/ EventSubscriber/ FinishResponseSubscriber.php, line 318
Class
- FinishResponseSubscriber
- Response subscriber to handle finished responses.
Namespace
Drupal\Core\EventSubscriberCode
protected function addDebugCacheHeaders(string $header, array $values, Response $response) : void {
sort($values);
$values_as_string = implode(static::RESPONSE_HEADER_CACHE_ITEM_SEPARATOR, $values);
$headers = explode("\n", wordwrap($values_as_string, static::RESPONSE_HEADER_LINE_MAX_LENGTH));
$response->headers
->set($header, $headers);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.