[HttpKernel] [HttpCache] Keep s-maxage=0 from ESI sub-responses
This commit is contained in:
parent
0fa07c6d7c
commit
ee7bc0272e
@ -81,8 +81,10 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
return;
|
||||
}
|
||||
|
||||
$this->storeRelativeAgeDirective('max-age', $response->headers->getCacheControlDirective('max-age'), $age);
|
||||
$this->storeRelativeAgeDirective('s-maxage', $response->headers->getCacheControlDirective('s-maxage') ?: $response->headers->getCacheControlDirective('max-age'), $age);
|
||||
$maxAge = $response->headers->hasCacheControlDirective('max-age') ? (int) $response->headers->getCacheControlDirective('max-age') : null;
|
||||
$this->storeRelativeAgeDirective('max-age', $maxAge, $age);
|
||||
$sharedMaxAge = $response->headers->hasCacheControlDirective('s-maxage') ? (int) $response->headers->getCacheControlDirective('s-maxage') : $maxAge;
|
||||
$this->storeRelativeAgeDirective('s-maxage', $sharedMaxAge, $age);
|
||||
|
||||
$expires = $response->getExpires();
|
||||
$expires = null !== $expires ? (int) $expires->format('U') - (int) $response->getDate()->format('U') : null;
|
||||
|
@ -377,6 +377,22 @@ class ResponseCacheStrategyTest extends TestCase
|
||||
],
|
||||
];
|
||||
|
||||
yield 's-maxage may be set to 0' => [
|
||||
['public' => true, 's-maxage' => '0', 'max-age' => null],
|
||||
['public' => true, 's-maxage' => '0'],
|
||||
[
|
||||
['public' => true, 's-maxage' => '60'],
|
||||
],
|
||||
];
|
||||
|
||||
yield 's-maxage may be set to 0, and works independently from maxage' => [
|
||||
['public' => true, 's-maxage' => '0', 'max-age' => '30'],
|
||||
['public' => true, 's-maxage' => '0', 'max-age' => '30'],
|
||||
[
|
||||
['public' => true, 'max-age' => '60'],
|
||||
],
|
||||
];
|
||||
|
||||
yield 'result is private when combining private responses' => [
|
||||
['no-cache' => false, 'must-revalidate' => false, 'private' => true],
|
||||
['s-maxage' => 60, 'private' => true],
|
||||
|
Reference in New Issue
Block a user