From f6d0bb419ede2acf2c7ef0e42d1647ff56bee085 Mon Sep 17 00:00:00 2001 From: Carl Schwan Date: Fri, 11 Feb 2022 22:14:04 +0100 Subject: Improve caching policy * Cache css with version in url. This makes most js and css requests to be cached by the browser * Force caching previews, the etag is in the url so that if the propfind gives a new etag, we will refresh it otherwise it's no use to try to fetch the new etag and do tons of DB queries Tested with firefox and 'debug' => false (important so that the js/css urls are generated with ?v= parameter) Signed-off-by: Carl Schwan --- lib/public/AppFramework/Http/Response.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php index ee10d483b25..1a84affbe57 100644 --- a/lib/public/AppFramework/Http/Response.php +++ b/lib/public/AppFramework/Http/Response.php @@ -103,10 +103,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 -- cgit v1.2.3