@@ -40,7 +40,12 @@ public function __construct(
4040 /**
4141 * @var bool indicates that any caches of any kind (public or shared) should not store this response.
4242 */
43- public bool $ public = true ,
43+ public bool $ public = false ,
44+
45+ /**
46+ * @var bool indicates that a public cache should not cache this
47+ */
48+ public bool $ private = false ,
4449
4550 /**
4651 * @var bool indicates that the response will not be updated while it's fresh.
@@ -68,6 +73,7 @@ public function with(
6873 bool |null $ proxyRevalidate = null ,
6974 bool |null $ noStore = null ,
7075 bool |null $ public = null ,
76+ bool |null $ private = null ,
7177 bool |null $ immutable = null ,
7278 int |null |false $ staleWhileRevalidating = false ,
7379 int |null |false $ staleIfError = false ,
@@ -80,6 +86,7 @@ public function with(
8086 proxyRevalidate: $ this ->withBool ($ this ->proxyRevalidate , $ proxyRevalidate ),
8187 noStore: $ this ->withBool ($ this ->noStore , $ noStore ),
8288 public: $ this ->withBool ($ this ->public , $ public ),
89+ private: $ this ->withBool ($ this ->private , $ private ),
8390 immutable: $ this ->withBool ($ this ->immutable , $ immutable ),
8491 staleWhileRevalidating: $ this ->withInt ($ this ->staleWhileRevalidating , $ staleWhileRevalidating ),
8592 staleIfError: $ this ->withInt ($ this ->staleIfError , $ staleIfError ),
@@ -99,7 +106,8 @@ private function withBool(bool $original, bool|null $var): bool
99106 public function render (): string
100107 {
101108 $ header = [
102- $ this ->public ? 'public ' : 'private ' ,
109+ ...$ this ->header ($ this ->private , 'private ' ),
110+ ...$ this ->header ($ this ->public , 'public ' ),
103111 ...$ this ->header ($ this ->maxAge , "max-age= $ this ->maxAge " ),
104112 ...$ this ->header ($ this ->sMaxAge , "s-maxage= $ this ->sMaxAge " ),
105113 ...$ this ->header ($ this ->noCache , "no-cache " ),
0 commit comments