public function Response::isNotModified

Determines if the Response validators (ETag, Last-Modified) match a conditional value specified in the Request.

If the Response is not modified, it sets the status code to 304 and removes the actual content by calling the setNotModified() method.

@api

Parameters

Request $request A Request instance:

Return value

Boolean true if the Response validators match the Request, false otherwise

File

drupal/core/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php, line 993

Class

Response
Response represents an HTTP response.

Namespace

Symfony\Component\HttpFoundation

Code

public function isNotModified(Request $request) {
  if (!$request
    ->isMethodSafe()) {
    return false;
  }
  $lastModified = $request->headers
    ->get('If-Modified-Since');
  $notModified = false;
  if ($etags = $request
    ->getEtags()) {
    $notModified = (in_array($this
      ->getEtag(), $etags) || in_array('*', $etags)) && (!$lastModified || $this->headers
      ->get('Last-Modified') == $lastModified);
  }
  elseif ($lastModified) {
    $notModified = $lastModified == $this->headers
      ->get('Last-Modified');
  }
  if ($notModified) {
    $this
      ->setNotModified();
  }
  return $notModified;
}