Add public argument to Http cacheFor()
Signed-off-by: Clement Wong <git@clement.hk>
This commit is contained in:
parent
1331eb1fb8
commit
203d85f045
|
@ -105,12 +105,11 @@ class Response {
|
||||||
* @return $this
|
* @return $this
|
||||||
* @since 6.0.0 - return value was added in 7.0.0
|
* @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) {
|
if ($cacheSeconds > 0) {
|
||||||
$this->addHeader('Cache-Control', 'private, max-age=' . $cacheSeconds . ', must-revalidate');
|
$pragma = $public ? 'public' : 'private';
|
||||||
|
$this->addHeader('Cache-Control', $pragma . ', max-age=' . $cacheSeconds . ', must-revalidate');
|
||||||
// Old scool prama caching
|
$this->addHeader('Pragma', $pragma);
|
||||||
$this->addHeader('Pragma', 'private');
|
|
||||||
|
|
||||||
// Set expires header
|
// Set expires header
|
||||||
$expires = new \DateTime();
|
$expires = new \DateTime();
|
||||||
|
|
Loading…
Reference in New Issue