$response =
new Response();
$response->headers->
set('Cache-Control', 's-maxage=600, max-age=0'
);
$this->
assertEquals(600,
$response->
getMaxAge(), '->getMaxAge() uses s-maxage cache control directive when present'
);
$response =
new Response();
$response->headers->
set('Cache-Control', 'max-age=600'
);
$this->
assertEquals(600,
$response->
getMaxAge(), '->getMaxAge() falls back to max-age when no s-maxage directive present'
);
$response =
new Response();
$response->headers->
set('Cache-Control', 'must-revalidate'
);
$response->headers->
set('Expires',
$this->
createDateTimeOneHourLater()->
format(\DATE_RFC2822
));
$this->
assertEquals(3600,
$response->
getMaxAge(), '->getMaxAge() falls back to Expires when no max-age or s-maxage directive present'
);
$response =
new Response();
$response->headers->
set('Expires', -1
);
$this->
assertSame(0,
$response->
getMaxAge());
$response =
new Response();
$this->
assertNull($response->
getMaxAge(), '->getMaxAge() returns null if no freshness information available'
);
} public function testSetSharedMaxAge() {