<?php
namespace App\EventSubscriber;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
class CacheabilitySubscriber implements EventSubscriberInterface
{
public function onResponse(ResponseEvent $event): void
{
if ('sonata_admin_dashboard' === $event->getRequest()->get('_route')) {
$event->getResponse()->headers->set(
'Cache-Control',
'no-cache, max-age=0, must-revalidate, no-store'
);
}
}
public static function getSubscribedEvents(): array
{
return [KernelEvents::RESPONSE => [['onResponse', 20]]];
}
}