<?php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class NoCacheSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
KernelEvents::RESPONSE => 'onKernelResponse',
];
}
public function onKernelResponse(ResponseEvent $event)
{
$response = $event->getResponse();
// Supprimer les en-tĂȘtes inutiles
$response->headers->remove('Cache-Control');
$response->headers->remove('Date');
$response->headers->remove('Expires');
$response->headers->remove('Pragma');
}
}