Add public argument to Http cacheFor()

Signed-off-by: Clement Wong <git@clement.hk>
This commit is contained in:
Clement Wong 2020-05-10 20:22:47 +02:00 committed by backportbot[bot]
parent 1331eb1fb8
commit 203d85f045
1 changed files with 4 additions and 5 deletions

View 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();