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

setExpires() public method

The given date must either be an RFC2822 parseable date string or a DateTime object. The timezone will be converted to GMT internally, but the point in time remains the same. In order to signal that the response has already expired, the date should be set to the same date as the Date header (that is, $now). To communicate an infinite expiration time, the date should be set to one year in the future. Expiration times should not be more than one year in the future, according to RFC 2616 / 14.21
public setExpires ( string | DateTime $date ) : Response
$date string | DateTime
return Response This response, for method chaining
    public function setExpires($date)
    {
        $this->headers->set('Expires', $date);
        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());
 }