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