diff options
author | Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | 2025-03-27 16:41:22 +0100 |
---|---|---|
committer | Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com> | 2025-03-27 17:00:22 +0100 |
commit | b83a4b59a5eca2e828c95e20651f8bed2ac53549 (patch) | |
tree | 3077c19cf858da518ee3fd28bc4e6b73fb75503f | |
parent | c359e620f5cca1349d0c79626f123efe6e3ef5c8 (diff) | |
download | nextcloud-server-perf/force-sending-ifnonematch.tar.gz nextcloud-server-perf/force-sending-ifnonematch.zip |
perf(cache): force Firefox to send cache headersperf/force-sending-ifnonematch
`immutable` header is only supported by Firefox and Safari.
When the resource is stale, Firefox don't send `If-None-Match` and
`If-Not-Modified-Since` headers.
This commit force Firefox to send these headers when resources are
stale.
Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
-rw-r--r-- | .htaccess | 2 | ||||
-rw-r--r-- | lib/public/AppFramework/Http/Response.php | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/.htaccess b/.htaccess index 164a630b75f..91b728847cf 100644 --- a/.htaccess +++ b/.htaccess @@ -49,7 +49,7 @@ # Add cache control for static resources <FilesMatch "\.(css|js|mjs|svg|gif|png|jpg|webp|ico|wasm|tflite)$"> <If "%{QUERY_STRING} =~ /(^|&)v=/"> - Header set Cache-Control "max-age=15778463, immutable" + Header set Cache-Control "max-age=15778463, must-revalidate, immutable" </If> <Else> Header set Cache-Control "max-age=15778463" diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php index 6fc3d4b98ea..93e305d2445 100644 --- a/lib/public/AppFramework/Http/Response.php +++ b/lib/public/AppFramework/Http/Response.php @@ -89,7 +89,7 @@ class Response { public function cacheFor(int $cacheSeconds, bool $public = false, bool $immutable = false) { if ($cacheSeconds > 0) { $cacheStore = $public ? 'public' : 'private'; - $this->addHeader('Cache-Control', sprintf('%s, max-age=%s, %s', $cacheStore, $cacheSeconds, ($immutable ? 'immutable' : 'must-revalidate'))); + $this->addHeader('Cache-Control', sprintf('%s, max-age=%s, %s', $cacheStore, $cacheSeconds, ($immutable ? 'must-revalidate, immutable' : 'must-revalidate'))); // Set expires header $expires = new \DateTime(); |