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

Breadcrumb

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

function HttpCache::mayServeStaleWhileRevalidate

Checks whether the given (cached) response may be served as "stale" when a revalidation is currently in progress.

1 call to HttpCache::mayServeStaleWhileRevalidate()
HttpCache::lock in vendor/symfony/http-kernel/HttpCache/HttpCache.php
Locks a Request during the call to the backend.

File

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

Class

HttpCache
Cache provides HTTP caching.

Namespace

Symfony\Component\HttpKernel\HttpCache

Code

private function mayServeStaleWhileRevalidate(Response $entry) : bool {
    $timeout = $entry->headers
        ->getCacheControlDirective('stale-while-revalidate');
    $timeout ??= $this->options['stale_while_revalidate'];
    $age = $entry->getAge();
    $maxAge = $entry->getMaxAge() ?? 0;
    $ttl = $maxAge - $age;
    return abs($ttl) < $timeout;
}

API Navigation

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