From cebed776ab93e8adfbb437dc0b1448ced9f71215 Mon Sep 17 00:00:00 2001 From: Daniel Hensby Date: Thu, 5 Jul 2018 22:52:04 +0100 Subject: [PATCH] FIX If theres a max-age set remove no-cache and no-store --- src/Control/Middleware/HTTPCacheControlMiddleware.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Control/Middleware/HTTPCacheControlMiddleware.php b/src/Control/Middleware/HTTPCacheControlMiddleware.php index 6ea8a2662..3bdf2d02b 100644 --- a/src/Control/Middleware/HTTPCacheControlMiddleware.php +++ b/src/Control/Middleware/HTTPCacheControlMiddleware.php @@ -522,6 +522,10 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable // Affect all non-disabled states $applyTo = [self::STATE_ENABLED, self::STATE_PRIVATE, self::STATE_PUBLIC, self::STATE_DEFAULT]; $this->setStateDirective($applyTo, 'max-age', $age); + if ($age) { + $this->removeStateDirective($applyTo, 'no-cache'); + $this->removeStateDirective($applyTo, 'no-store'); + } return $this; } @@ -538,6 +542,10 @@ class HTTPCacheControlMiddleware implements HTTPMiddleware, Resettable // Affect all non-disabled states $applyTo = [self::STATE_ENABLED, self::STATE_PRIVATE, self::STATE_PUBLIC, self::STATE_DEFAULT]; $this->setStateDirective($applyTo, 's-maxage', $age); + if ($age) { + $this->removeStateDirective($applyTo, 'no-cache'); + $this->removeStateDirective($applyTo, 'no-store'); + } return $this; }