<?php
namespace AppBundleListener;
use SymfonyComponentHttpKernelEventFilterResponseEvent;
class ResponseListener
{
public function onKernelResponse(FilterResponseEvent $event)
{
$response = $event->getResponse();
$controller = $event->getRequest()->attributes->get('_controller');
$requiredAssetAction = "AppBundleControllerWebsiteAssetsController::assetAction";
if ($controller == $requiredAssetAction) {
$response->headers->addCacheControlDirective('max-age', 900);
$response->headers->addCacheControlDirective('s-maxage', 900);
$response->headers->addCacheControlDirective('must-revalidate', true);
$response->headers->addCacheControlDirective('public', true);
$response->headers->removeCacheControlDirective('private');
}
$event->setResponse($response);
}
}