Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/public/AppFramework/Http/Response.php9
-rw-r--r--tests/lib/AppFramework/Http/ResponseTest.php2
2 files changed, 5 insertions, 6 deletions
diff --git a/lib/public/AppFramework/Http/Response.php b/lib/public/AppFramework/Http/Response.php
index a48580c789d..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', 'max-age=' . $cacheSeconds . ', must-revalidate');
-
- // Old scool prama caching
- $this->addHeader('Pragma', 'public');
+ $pragma = $public ? 'public' : 'private';
+ $this->addHeader('Cache-Control', $pragma . ', max-age=' . $cacheSeconds . ', must-revalidate');
+ $this->addHeader('Pragma', $pragma);
// Set expires header
$expires = new \DateTime();
diff --git a/tests/lib/AppFramework/Http/ResponseTest.php b/tests/lib/AppFramework/Http/ResponseTest.php
index e6f88b6a6e9..f33d0a0089d 100644
--- a/tests/lib/AppFramework/Http/ResponseTest.php
+++ b/tests/lib/AppFramework/Http/ResponseTest.php
@@ -267,7 +267,7 @@ class ResponseTest extends \Test\TestCase {
$this->assertEquals(Http::STATUS_NOT_FOUND, $this->childResponse->getStatus());
$this->assertEquals('hi', $this->childResponse->getEtag());
$this->assertEquals('Thu, 01 Jan 1970 00:00:01 +0000', $headers['Last-Modified']);
- $this->assertEquals('max-age=33, must-revalidate',
+ $this->assertEquals('private, max-age=33, must-revalidate',
$headers['Cache-Control']);
}