<?php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class HttpSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents(): array {
return [
KernelEvents::RESPONSE => 'onResponse',
];
}
public function onResponse(ResponseEvent $event) {
$headers = $event->getResponse()->headers;
$headers->addCacheControlDirective('no-cache, no-store, max-age=0, must-revalidate');
$headers->set('Pragma', 'no-cache');
$headers->set('Expires', '0');
}
}