isFresh() public method

Fresh responses may be served from cache without any interaction with the origin. A response is considered fresh when it includes a Cache-Control/max-age indicator or Expires header and the calculated age is less than the freshness lifetime.
public isFresh ( ) : boolean
return boolean true if the response is fresh, false otherwise
Esempio n. 1
0
 /**
  * {@inheritDoc}
  */
 protected function isFreshEnough(Request $request, Response $entry)
 {
     if (!$entry->isFresh() && !$this->isFreshCacheEntry($entry)) {
         return $this->lock($request, $entry);
     }
     return true;
 }
Esempio n. 2
0
 /**
  * Checks whether the cache entry is "fresh enough" to satisfy the Request.
  *
  * @param Request  $request A Request instance
  * @param Response $entry   A Response instance
  *
  * @return bool true if the cache entry if fresh enough, false otherwise
  */
 protected function isFreshEnough(Request $request, Response $entry)
 {
     if (!$entry->isFresh()) {
         return $this->lock($request, $entry);
     }
     if ($this->options['allow_revalidate'] && null !== ($maxAge = $request->headers->getCacheControlDirective('max-age'))) {
         return $maxAge > 0 && $maxAge >= $entry->getAge();
     }
     return true;
 }