]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add public argument to Http cacheFor()
authorClement Wong <git@clement.hk>
Sun, 10 May 2020 18:22:47 +0000 (20:22 +0200)
committerClement Wong <git@clement.hk>
Sun, 10 May 2020 18:24:14 +0000 (20:24 +0200)
Signed-off-by: Clement Wong <git@clement.hk>
lib/public/AppFramework/Http/Response.php

index 27a2fd3a008667366b7ef62d5c37003c135f8f27..6f418e42553e3e4a2f0698a7cb00d6dc3c7d940f 100644 (file)
@@ -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();