From e2fda60ce5792611682f16613f7d0f397899d28b Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 23 Jan 2019 16:32:15 +0100 Subject: [PATCH] Fix usage of symfony cache with shared max age 0 --- CHANGELOG.md | 1 + src/Sulu/Component/HttpCache/Handler/PublicHandler.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ace4f07769..cdf4fb25b02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ CHANGELOG for Sulu ================== * release/1.5 + * BUGFIX #4385 [SuluHttpCacheBundle] Fix usage of symfony cache with s-max-age 0 * ENHANCEMENT #4367 [WebsiteBundle] Remove false deprecation of WebsiteController::renderStructure * BUGFIX #4376 [SecurityBundle] Exclude role permissions in user API to improve performance diff --git a/src/Sulu/Component/HttpCache/Handler/PublicHandler.php b/src/Sulu/Component/HttpCache/Handler/PublicHandler.php index 4b08a3da328..b6d35c36727 100644 --- a/src/Sulu/Component/HttpCache/Handler/PublicHandler.php +++ b/src/Sulu/Component/HttpCache/Handler/PublicHandler.php @@ -85,9 +85,13 @@ public function updateResponse(Response $response, StructureInterface $structure // mark the response as either public or private $response->setPublic(); - // set the private and shared max age + // set the private max age $response->setMaxAge($this->maxAge); - $response->setSharedMaxAge($this->sharedMaxAge); + + // set shared max age only when not 0 else symfony cache will not work + if ($this->sharedMaxAge) { + $response->setSharedMaxAge($this->sharedMaxAge); + } $proxyTtl = $this->usePageTtl ? $response->getAge() + $cacheLifetime :