From 401210d259be88918ea880aa32fde9e81fbe8bb2 Mon Sep 17 00:00:00 2001 From: Clement Wong Date: Sun, 10 May 2020 11:06:56 +0200 Subject: Proxy server could cache http response when it is not private Signed-off-by: Clement Wong --- lib/public/AppFramework/Http/Response.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/public/AppFramework/Http') diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php index a48580c789d..27a2fd3a008 100644 --- a/lib/public/AppFramework/Http/Response.php +++ b/lib/public/AppFramework/Http/Response.php @@ -107,10 +107,10 @@ class Response { */ public function cacheFor(int $cacheSeconds) { if ($cacheSeconds > 0) { - $this->addHeader('Cache-Control', 'max-age=' . $cacheSeconds . ', must-revalidate'); + $this->addHeader('Cache-Control', 'private, max-age=' . $cacheSeconds . ', must-revalidate'); // Old scool prama caching - $this->addHeader('Pragma', 'public'); + $this->addHeader('Pragma', 'private'); // Set expires header $expires = new \DateTime(); -- cgit v1.2.3 From e9be3a9090d89f7d3e4c2c0ec51ed4e68499985d Mon Sep 17 00:00:00 2001 From: Clement Wong Date: Sun, 10 May 2020 20:22:47 +0200 Subject: Add public argument to Http cacheFor() Signed-off-by: Clement Wong --- lib/public/AppFramework/Http/Response.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib/public/AppFramework/Http') diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php index 27a2fd3a008..6f418e42553 100644 --- a/lib/public/AppFramework/Http/Response.php +++ b/lib/public/AppFramework/Http/Response.php @@ -105,12 +105,11 @@ class Response { * @return $this * @since 6.0.0 - return value was added in 7.0.0 */ - public function cacheFor(int $cacheSeconds) { + public function cacheFor(int $cacheSeconds, bool $public = false) { if ($cacheSeconds > 0) { - $this->addHeader('Cache-Control', 'private, max-age=' . $cacheSeconds . ', must-revalidate'); - - // Old scool prama caching - $this->addHeader('Pragma', 'private'); + $pragma = $public ? 'public' : 'private'; + $this->addHeader('Cache-Control', $pragma . ', max-age=' . $cacheSeconds . ', must-revalidate'); + $this->addHeader('Pragma', $pragma); // Set expires header $expires = new \DateTime(); -- cgit v1.2.3