protected function HttpCache::invalidate

Invalidates non-safe methods (like POST, PUT, and DELETE).

Parameters

Request $request A Request instance:

Boolean $catch Whether to process exceptions:

Return value

Response A Response instance

Throws

\Exception

See also

RFC2616 13.10

1 call to HttpCache::invalidate()
HttpCache::handle in drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php
@api

File

drupal/core/vendor/symfony/http-kernel/Symfony/Component/HttpKernel/HttpCache/HttpCache.php, line 259

Class

HttpCache
Cache provides HTTP caching.

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

protected function invalidate(Request $request, $catch = false) {
  $response = $this
    ->pass($request, $catch);

  // invalidate only when the response is successful
  if ($response
    ->isSuccessful() || $response
    ->isRedirect()) {
    try {
      $this->store
        ->invalidate($request, $catch);

      // As per the RFC, invalidate Location and Content-Location URLs if present
      foreach (array(
        'Location',
        'Content-Location',
      ) as $header) {
        if ($uri = $response->headers
          ->get($header)) {
          $subRequest = $request::create($uri, 'get', array(), array(), array(), $request->server
            ->all());
          $this->store
            ->invalidate($subRequest);
        }
      }
      $this
        ->record($request, 'invalidate');
    } catch (\Exception $e) {
      $this
        ->record($request, 'invalidate-failed');
      if ($this->options['debug']) {
        throw $e;
      }
    }
  }
  return $response;
}