src/EventSubscriber/HttpSubscriber.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber;
  3. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  4. use Symfony\Component\HttpKernel\Event\RequestEvent;
  5. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  6. use Symfony\Component\HttpKernel\KernelEvents;
  7. class HttpSubscriber implements EventSubscriberInterface {
  8.     public static function getSubscribedEvents(): array {
  9.         return [
  10.             KernelEvents::RESPONSE => 'onResponse',
  11.         ];
  12.     }
  13.     public function onResponse(ResponseEvent $event) {
  14.         $headers $event->getResponse()->headers;
  15.         $headers->addCacheControlDirective('no-cache, no-store, max-age=0, must-revalidate');
  16.         $headers->set('Pragma''no-cache');
  17.         $headers->set('Expires''0');
  18.     }
  19. }