You are here

protected function HtmlResponseSubscriber::addPreconnectLinkHeaders in CDN 8.3

Adds preconnect link headers to the HTML response.

Parameters

\Drupal\Core\Render\HtmlResponse $response: The HTML response to update.

See also

https://www.w3.org/TR/resource-hints/#preconnect

File

src/EventSubscriber/HtmlResponseSubscriber.php, line 75

Class

HtmlResponseSubscriber

Namespace

Drupal\cdn\EventSubscriber

Code

protected function addPreconnectLinkHeaders(HtmlResponse $response) {
  foreach ($this->settings
    ->getDomains() as $domain) {
    $response->headers
      ->set('Link', '<//' . $domain . '>; rel=preconnect; crossorigin', FALSE);
  }
}