You are here

protected function ResponseHeaderBag::computeCacheControlValue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-foundation/ResponseHeaderBag.php \Symfony\Component\HttpFoundation\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 vendor/symfony/http-foundation/ResponseHeaderBag.php
Sets a header by name.

File

vendor/symfony/http-foundation/ResponseHeaderBag.php, line 281

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;
}