diff --git a/src/Resources/ResourceFactory.php b/src/Resources/ResourceFactory.php index 7bab12e..7aa18f4 100644 --- a/src/Resources/ResourceFactory.php +++ b/src/Resources/ResourceFactory.php @@ -145,6 +145,8 @@ public static function create(DispatchResource $resource, $cache = true) $response->setEtag($resource->getHash()); $response->setPublic(); + $response->setImmutable($cache->isImmutable()); + //This resource should last for 1 year in cache $response->setMaxAge($cache->getCacheSeconds()); $response->setSharedMaxAge($cache->getCacheSeconds()); diff --git a/src/ResponseCacheConfig.php b/src/ResponseCacheConfig.php index effd8c9..1877108 100644 --- a/src/ResponseCacheConfig.php +++ b/src/ResponseCacheConfig.php @@ -5,6 +5,7 @@ class ResponseCacheConfig { protected $_varyHeader = 'Accept-Encoding, Accept'; protected $_cacheSeconds = 31536000; + protected $_immutable = true; /** * @return string @@ -44,4 +45,23 @@ public function setCacheSeconds(int $cacheTimeSeconds) return $this; } + /** + * @return bool + */ + public function isImmutable(): bool + { + return $this->_immutable; + } + + /** + * @param bool $immutable + * + * @return ResponseCacheConfig + */ + public function setImmutable(bool $immutable) + { + $this->_immutable = $immutable; + return $this; + } + }