diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-02-17 18:58:35 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-17 18:58:35 +0300 |
commit | ac4978e715862ec9e86150b1171296629eebeced (patch) | |
tree | dfb1705f6687f501c2c6e1cd69680410e94db81e /lib | |
parent | 098dfe15c1e932a2acc8bb4853979040339a3ad7 (diff) | |
parent | 7dddbd0c355d1b4761466f9f86b30aed8b112ba1 (diff) |
Merge pull request #31141 from nextcloud/fix/better-cache-policy
Improve caching policy use immutable when loading versionned assets
Diffstat (limited to 'lib')
-rw-r--r-- | lib/public/AppFramework/Http/Response.php | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php index ad2280ab9da..6febef838cf 100644 --- a/lib/public/AppFramework/Http/Response.php +++ b/lib/public/AppFramework/Http/Response.php @@ -110,10 +110,10 @@ class Response { * @return $this * @since 6.0.0 - return value was added in 7.0.0 */ - public function cacheFor(int $cacheSeconds, bool $public = false) { + public function cacheFor(int $cacheSeconds, bool $public = false, bool $immutable = false) { if ($cacheSeconds > 0) { $pragma = $public ? 'public' : 'private'; - $this->addHeader('Cache-Control', $pragma . ', max-age=' . $cacheSeconds . ', must-revalidate'); + $this->addHeader('Cache-Control', sprintf('%s, max-age=%s, %s', $pragma, $cacheSeconds, ($immutable ? 'immutable' : 'must-revalidate'))); $this->addHeader('Pragma', $pragma); // Set expires header |