protected function ResponseHeaderBag::computeCacheControlValue

Returns the calculated value of the cache-control header.

This considers several other headers and calculates or modifies the cache-control header to a sensible, conservative value.

Return value

string

1 call to ResponseHeaderBag::computeCacheControlValue()
ResponseHeaderBag::set in drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php
@api

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/ResponseHeaderBag.php, line 270

Class

ResponseHeaderBag
ResponseHeaderBag is a container for Response HTTP headers.

Namespace

Symfony\Component\HttpFoundation

Code

protected function computeCacheControlValue() {
  if (!$this->cacheControl && !$this
    ->has('ETag') && !$this
    ->has('Last-Modified') && !$this
    ->has('Expires')) {
    return 'no-cache';
  }
  if (!$this->cacheControl) {

    // conservative by default
    return 'private, must-revalidate';
  }
  $header = $this
    ->getCacheControlHeader();
  if (isset($this->cacheControl['public']) || isset($this->cacheControl['private'])) {
    return $header;
  }

  // public if s-maxage is defined, private otherwise
  if (!isset($this->cacheControl['s-maxage'])) {
    return $header . ', private';
  }
  return $header;
}