Skip to content

Commit e9be3a9

Browse files
committed
Add public argument to Http cacheFor()
Signed-off-by: Clement Wong <[email protected]>
1 parent 401210d commit e9be3a9

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/public/AppFramework/Http/Response.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,11 @@ public function __construct() {
105105
* @return $this
106106
* @since 6.0.0 - return value was added in 7.0.0
107107
*/
108-
public function cacheFor(int $cacheSeconds) {
108+
public function cacheFor(int $cacheSeconds, bool $public = false) {
109109
if ($cacheSeconds > 0) {
110-
$this->addHeader('Cache-Control', 'private, max-age=' . $cacheSeconds . ', must-revalidate');
111-
112-
// Old scool prama caching
113-
$this->addHeader('Pragma', 'private');
110+
$pragma = $public ? 'public' : 'private';
111+
$this->addHeader('Cache-Control', $pragma . ', max-age=' . $cacheSeconds . ', must-revalidate');
112+
$this->addHeader('Pragma', $pragma);
114113

115114
// Set expires header
116115
$expires = new \DateTime();

0 commit comments

Comments
 (0)