isExpired method

bool isExpired(
  1. CacheControl rqCacheCtrl
)

Checks if response is expired.

Implementation

bool isExpired(CacheControl rqCacheCtrl) {
  final respCacheCtrl = cacheControl;

  final ageMillis = _cacheResponseAge();

  var freshMillis = _computeFreshnessLifetime();
  final maxAge = rqCacheCtrl.maxAge;
  if (maxAge != -1) {
    freshMillis = min(freshMillis, maxAge * 1000);
  }

  var maxStaleMillis = 0;
  final maxStale = rqCacheCtrl.maxStale;
  if (!respCacheCtrl.mustRevalidate && maxStale != -1) {
    maxStaleMillis = maxStale * 1000;
  }

  var minFreshMillis = 0;
  final minFresh = rqCacheCtrl.minFresh;
  if (minFresh != -1) {
    minFreshMillis = minFresh * 1000;
  }

  if (ageMillis + minFreshMillis < freshMillis + maxStaleMillis) {
    return false;
  }

  return true;
}