diff options
author | Nicolas Guichard <nicolas@guichard.eu> | 2023-03-02 18:38:04 +0100 |
---|---|---|
committer | backportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com> | 2023-03-15 22:35:18 +0000 |
commit | 4bcb38c0b26f02081d1483c81bfc2ea500d6ff3b (patch) | |
tree | 6bdb4e2ce85fcf0dc195fbc2e9c1e12bf1da3e2c /.htaccess | |
parent | 4c161a70a4f24c42b3bd37faa6e452b72fe1b100 (diff) | |
download | nextcloud-server-4bcb38c0b26f02081d1483c81bfc2ea500d6ff3b.tar.gz nextcloud-server-4bcb38c0b26f02081d1483c81bfc2ea500d6ff3b.zip |
Fix Cache-Control header of non-versioned assets
Non-cache-busted assets such as /dist/core-main.js also matched the
regex meant for cache-busted assets (note the ? at the end of the
regex).
The FilesMatch directive for cache-busted assets coming after the
non-cache-busted version all assets actually got the immutable flag
in their Cache-Control header. This caused client-side errors on
updates.
Query strings are not actually passed to FilesMatch directives so we
need another way to tell cache-busted/versionned assets apart from
non-versioned assets, here using If/Else directives.
Signed-off-by: Nicolas Guichard <nicolas@guichard.eu>
Diffstat (limited to '.htaccess')
-rw-r--r-- | .htaccess | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/.htaccess b/.htaccess index dd0fce231e8..956e29ea7c4 100644 --- a/.htaccess +++ b/.htaccess @@ -41,11 +41,12 @@ # Add cache control for static resources <FilesMatch "\.(css|js|svg|gif|png|jpg|ico|wasm|tflite)$"> - Header set Cache-Control "max-age=15778463" - </FilesMatch> - - <FilesMatch "\.(css|js|svg|gif|png|jpg|ico|wasm|tflite)(\?v=.*)?$"> - Header set Cache-Control "max-age=15778463, immutable" + <If "%{QUERY_STRING} =~ /(^|&)v=/"> + Header set Cache-Control "max-age=15778463, immutable" + </If> + <Else> + Header set Cache-Control "max-age=15778463" + </Else> </FilesMatch> # Let browsers cache WOFF files for a week |