summaryrefslogtreecommitdiffstats
path: root/lib/public
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-02-11 22:14:04 +0100
committerCarl Schwan <carl@carlschwan.eu>2022-02-16 11:35:57 +0100
commit7dddbd0c355d1b4761466f9f86b30aed8b112ba1 (patch)
treeb782783ff0b88277e79a5ce3b5115f47a4b240f0 /lib/public
parentfbbbc2ec3445aa777f56c97a0a383a2e8566be54 (diff)
downloadnextcloud-server-7dddbd0c355d1b4761466f9f86b30aed8b112ba1.tar.gz
nextcloud-server-7dddbd0c355d1b4761466f9f86b30aed8b112ba1.zip
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 <carl@carlschwan.eu>
Diffstat (limited to 'lib/public')
-rw-r--r--lib/public/AppFramework/Http/Response.php4
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