1<?php
2
3namespace AppBundle\Listener;
4
5use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
6
7class ResponseListener
8{
9 public function onKernelResponse(FilterResponseEvent $event)
10 {
11 $response = $event->getResponse();
12
13 $controller = $event->getRequest()->attributes->get('_controller');
14 $requiredAssetAction = "AppBundle\Controller\Website\AssetsController::assetAction";
15
16 if ($controller == $requiredAssetAction) {
17 $response->headers->addCacheControlDirective('max-age', 900);
18 $response->headers->addCacheControlDirective('s-maxage', 900);
19 $response->headers->addCacheControlDirective('must-revalidate', true);
20 $response->headers->addCacheControlDirective('public', true);
21 $response->headers->removeCacheControlDirective('private');
22
23 }
24
25 $event->setResponse($response);
26 }
27
28}