diff --git a/src/EventSubscriber/CacheHeadersSubscriber.php b/src/EventSubscriber/CacheHeadersSubscriber.php new file mode 100755 index 0000000..e407d53 --- /dev/null +++ b/src/EventSubscriber/CacheHeadersSubscriber.php @@ -0,0 +1,37 @@ +params = $params; + } + + public function onResponse(ResponseEvent $event) + { + $response = $event->getResponse(); + $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); + } + + public static function getSubscribedEvents() + { + return [ + KernelEvents::RESPONSE => 'onResponse' + ]; + } +} \ No newline at end of file diff --git a/src/EventSubscriber/SecurityHeadersSubscriber.php b/src/EventSubscriber/SecurityHeadersSubscriber.php old mode 100644 new mode 100755 index 9bd80d6..f924a35 --- a/src/EventSubscriber/SecurityHeadersSubscriber.php +++ b/src/EventSubscriber/SecurityHeadersSubscriber.php @@ -24,6 +24,8 @@ class SecurityHeadersSubscriber implements EventSubscriberInterface $referer = $securitypolicy['referer_policy']; $response->headers->set("Content-Security-Policy", $csp); $response->headers->set("Referrer-Policy", $referer); + + $event->setResponse($response); } public static function getSubscribedEvents()