From 7ec0774c5c427fc2ee25b76728ddfdf2d1a47de6 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Mon, 22 Jul 2024 16:00:11 +0200 Subject: [PATCH] Never us shared max age if CustomTtlListener is enabled --- src/SymfonyCache/CustomTtlListener.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/SymfonyCache/CustomTtlListener.php b/src/SymfonyCache/CustomTtlListener.php index 850fe184..8ee98f58 100644 --- a/src/SymfonyCache/CustomTtlListener.php +++ b/src/SymfonyCache/CustomTtlListener.php @@ -59,15 +59,16 @@ public function __construct($ttlHeader = 'X-Reverse-Proxy-TTL', $keepTtlHeader = public function useCustomTtl(CacheEvent $e) { $response = $e->getResponse(); - if (!$response->headers->has($this->ttlHeader)) { - return; - } $backup = $response->headers->hasCacheControlDirective('s-maxage') ? $response->headers->getCacheControlDirective('s-maxage') : 'false' ; $response->headers->set(static::SMAXAGE_BACKUP, $backup); - $response->setTtl($response->headers->get($this->ttlHeader)); + $response->setTtl( + $response->headers->has($this->ttlHeader) + ? $response->headers->get($this->ttlHeader) + : 0 + ); } /**