Skip to content

Commit ae57ea7

Browse files
committed
Support immutable
1 parent 5ef05f8 commit ae57ea7

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/Resources/ResourceFactory.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ public static function create(DispatchResource $resource, $cache = true)
145145
$response->setEtag($resource->getHash());
146146
$response->setPublic();
147147

148+
$response->setImmutable($cache->isImmutable());
149+
148150
//This resource should last for 1 year in cache
149151
$response->setMaxAge($cache->getCacheSeconds());
150152
$response->setSharedMaxAge($cache->getCacheSeconds());

src/ResponseCacheConfig.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class ResponseCacheConfig
55
{
66
protected $_varyHeader = 'Accept-Encoding, Accept';
77
protected $_cacheSeconds = 31536000;
8+
protected $_immutable = true;
89

910
/**
1011
* @return string
@@ -44,4 +45,23 @@ public function setCacheSeconds(int $cacheTimeSeconds)
4445
return $this;
4546
}
4647

48+
/**
49+
* @return bool
50+
*/
51+
public function isImmutable(): bool
52+
{
53+
return $this->_immutable;
54+
}
55+
56+
/**
57+
* @param bool $immutable
58+
*
59+
* @return ResponseCacheConfig
60+
*/
61+
public function setImmutable(bool $immutable)
62+
{
63+
$this->_immutable = $immutable;
64+
return $this;
65+
}
66+
4767
}

0 commit comments

Comments
 (0)