Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HttpCache.php

function HttpCache::invalidate

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

Parameters

bool $catch Whether to process exceptions:

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 274

Class

HttpCache
Cache provides HTTP caching.

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

protected function invalidate(Request $request, bool $catch = false) : Response {
    $response = $this->pass($request, $catch);
    // invalidate only when the response is successful
    if ($response->isSuccessful() || $response->isRedirect()) {
        try {
            $this->store
                ->invalidate($request);
            // As per the RFC, invalidate Location and Content-Location URLs if present
            foreach ([
                'Location',
                'Content-Location',
            ] as $header) {
                if ($uri = $response->headers
                    ->get($header)) {
                    $subRequest = Request::create($uri, 'get', [], [], [], $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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal