public function testMaxAge() { $value = $this->object->getMaxAge(); $this->assertNull($value); $expected = 55; $this->object->setMaxAge($expected); $value = $this->object->getMaxAge(); $this->assertEquals($expected, $value); }
public function onFinish(MvcEvent $e) { /** @var $response Response */ $response = $e->getResponse(); if (!$response instanceof Response) { return; } $headers = $response->getHeaders(); /** @var $lastModified LastModified */ $lastModified = $headers->get('Last-Modified'); if (!$lastModified instanceof LastModified) { $lastModified = new LastModified(); $headers->addHeader($lastModified); } /** @var $cacheControl CacheControl */ $cacheControl = $headers->get('Cache-Control'); if ($cacheControl instanceof CacheControl) { // Nope, you send it... i won't modified it. return; } $cacheControl = new CacheControl(); $headers->addHeader($cacheControl); if (null !== ($value = $this->config->getMaxAge())) { $cacheControl->addDirective('max-age', $value); } if (null !== ($value = $this->config->getSMaxAge())) { $cacheControl->addDirective('s-maxage', $value); } if ($this->config->istMustRevalidate()) { $cacheControl->addDirective('must-revalidate'); } }