You are here

protected function HttpCache::invalidate in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/HttpCache/HttpCache.php \Symfony\Component\HttpKernel\HttpCache\HttpCache::invalidate()

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

Parameters

Request $request A Request instance:

bool $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 vendor/symfony/http-kernel/HttpCache/HttpCache.php
Handles a Request to convert it to a Response.

File

vendor/symfony/http-kernel/HttpCache/HttpCache.php, line 273

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