hasCacheControlDirective() public method

Returns true if the Cache-Control directive is defined.
public hasCacheControlDirective ( string $key ) : boolean
$key string The Cache-Control directive
return boolean true if the directive exists, false otherwise
 public function testCacheControlDirectiveOverrideWithReplace()
 {
     $bag = new HeaderBag(array('cache-control' => 'private, max-age=100'));
     $bag->replace(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'));
 }
Example #2
0
 /**
  * @return bool
  */
 public function isNoCache()
 {
     return $this->headers->hasCacheControlDirective('no-cache') || 'no-cache' == $this->headers->get('Pragma');
 }
Example #3
0
 /**
  * Returns true if the response must be revalidated by caches.
  *
  * This method indicates that the response must not be served stale by a
  * cache in any circumstance without first revalidating with the origin.
  * When present, the TTL of the response should not be overridden to be
  * greater than the value provided by the origin.
  *
  * @return Boolean true if the response must be revalidated by a cache, false otherwise
  */
 public function mustRevalidate()
 {
     return $this->headers->hasCacheControlDirective('must-revalidate') || $this->headers->has('must-proxy-revalidate');
 }