You are here

public function HtmlResponseSubscriber::onRespond in CDN 8.3

Parameters

\Symfony\Component\HttpKernel\Event\FilterResponseEvent $event: The event to process.

File

src/EventSubscriber/HtmlResponseSubscriber.php, line 32

Class

HtmlResponseSubscriber

Namespace

Drupal\cdn\EventSubscriber

Code

public function onRespond(FilterResponseEvent $event) {
  $response = $event
    ->getResponse();
  if (!$response instanceof HtmlResponse) {
    return;
  }
  if (!$this->settings
    ->isEnabled()) {
    return;
  }

  // Optimal, so first.
  $this
    ->addPreConnectLinkHeaders($response);

  // Fallback, so second.
  $this
    ->addDnsPrefetchLinkHeaders($response);
}