@@ -36,7 +36,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
36
36
/**
37
37
* Cache-Control headers that are sent to the final response if the appear in ALL of the responses.
38
38
*/
39
- private static $ inheritDirectives = array ('public ' , ' private ' , ' immutable ' );
39
+ private static $ inheritDirectives = array ('immutable ' );
40
40
41
41
private $ embeddedResponses = 0 ;
42
42
private $ isNotCacheableResponseEmbedded = false ;
@@ -76,6 +76,14 @@ public function add(Response $response)
76
76
}
77
77
}
78
78
79
+ if (false !== $ this ->flagDirectives ['public ' ]) {
80
+ $ this ->flagDirectives ['public ' ] = $ response ->headers ->hasCacheControlDirective ('public ' );
81
+ }
82
+
83
+ if (false !== $ this ->flagDirectives ['private ' ]) {
84
+ $ this ->flagDirectives ['private ' ] = $ response ->headers ->hasCacheControlDirective ('private ' ) || $ response ->headers ->hasCacheControlDirective ('public ' );
85
+ }
86
+
79
87
$ age = $ response ->getAge ();
80
88
$ this ->age = max ($ this ->age , $ age );
81
89
@@ -124,7 +132,13 @@ public function update(Response $response)
124
132
return ;
125
133
}
126
134
127
- $ response ->headers ->set ('Cache-Control ' , implode (', ' , array_keys (array_filter ($ this ->flagDirectives ))));
135
+ $ flags = array_filter ($ this ->flagDirectives );
136
+
137
+ if (isset ($ flags ['public ' ], $ flags ['private ' ])) {
138
+ unset($ flags ['private ' ]);
139
+ }
140
+
141
+ $ response ->headers ->set ('Cache-Control ' , implode (', ' , array_keys ($ flags )));
128
142
129
143
if ($ this ->ageDirectives ['max-age ' ]) {
130
144
$ response ->headers ->addCacheControlDirective ('max-age ' , $ this ->ageDirectives ['max-age ' ] + $ this ->age );
0 commit comments