Add public argument to Http cacheFor()
Signed-off-by: Clement Wong <git@clement.hk>
This commit is contained in:
parent
401210d259
commit
e9be3a9090
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue