Adds a custom Cache-Control directive.
public addCacheControlDirective ( string $key, mixed $value = true ) | ||
$key | string | The Cache-Control directive name |
$value | mixed | The Cache-Control directive value |
public function testCacheControlDirectiveParsing() { $bag = new HeaderBag(array('cache-control' => 'public, max-age=10')); $this->assertTrue($bag->hasCacheControlDirective('public')); $this->assertTrue($bag->getCacheControlDirective('public')); $this->assertTrue($bag->hasCacheControlDirective('max-age')); $this->assertEquals(10, $bag->getCacheControlDirective('max-age')); $bag->addCacheControlDirective('s-maxage', 100); $this->assertEquals('max-age=10, public, s-maxage=100', $bag->get('cache-control')); }
/** * Sets the number of seconds after which the response should no longer be considered fresh by shared caches. * * This methods sets the Cache-Control s-maxage directive. * * @param integer $value A number of seconds */ public function setSharedMaxAge($value) { $this->headers->addCacheControlDirective('s-maxage', $value); }