Skip to content

Commit b83a4b5

Browse files
committed
perf(cache): force Firefox to send cache headers
`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>
1 parent c359e62 commit b83a4b5

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

.htaccess

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
# Add cache control for static resources
5050
<FilesMatch "\.(css|js|mjs|svg|gif|png|jpg|webp|ico|wasm|tflite)$">
5151
<If "%{QUERY_STRING} =~ /(^|&)v=/">
52-
Header set Cache-Control "max-age=15778463, immutable"
52+
Header set Cache-Control "max-age=15778463, must-revalidate, immutable"
5353
</If>
5454
<Else>
5555
Header set Cache-Control "max-age=15778463"

lib/public/AppFramework/Http/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function __construct(int $status = Http::STATUS_OK, array $headers = [])
8989
public function cacheFor(int $cacheSeconds, bool $public = false, bool $immutable = false) {
9090
if ($cacheSeconds > 0) {
9191
$cacheStore = $public ? 'public' : 'private';
92-
$this->addHeader('Cache-Control', sprintf('%s, max-age=%s, %s', $cacheStore, $cacheSeconds, ($immutable ? 'immutable' : 'must-revalidate')));
92+
$this->addHeader('Cache-Control', sprintf('%s, max-age=%s, %s', $cacheStore, $cacheSeconds, ($immutable ? 'must-revalidate, immutable' : 'must-revalidate')));
9393

9494
// Set expires header
9595
$expires = new \DateTime();

0 commit comments

Comments
 (0)