Neos\Flow\Http\Response::setMaximumAge PHP Method

setMaximumAge() public method

This method sets the "max-age" directive in the Cache-Control header.
public setMaximumAge ( integer $age ) : Response
$age integer The maximum age in seconds
return Response This response, for method chaining
    public function setMaximumAge($age)
    {
        $this->headers->setCacheControlDirective('max-age', $age);
        return $this;
    }

Usage Example

 /**
  * RFC 2616 / 14.21 (Expires)
  *
  * @test
  */
 public function makeStandardsCompliantRemovesMaxAgeDireciveIfExpiresHeaderIsPresent()
 {
     $now = \DateTime::createFromFormat(DATE_RFC2822, 'Tue, 22 May 2012 12:00:00 GMT');
     $later = \DateTime::createFromFormat(DATE_RFC2822, 'Wed, 23 May 2012 12:00:00 GMT');
     $request = Request::create(new Uri('http://localhost'));
     $response = new Response();
     $response->setNow($now);
     $response->setMaximumAge(60);
     $response->setExpires($later);
     $response->makeStandardsCompliant($request);
     $this->assertSame(null, $response->getHeaders()->getCacheControlDirective('max-age'));
     $this->assertEquals($later, $response->getExpires());
 }