parameters: (self)
return_statement: return result
docstring: Returns [freshness, stale-while-revalidate freshness] in seconds.
docstring_summary: Returns [freshness, stale-while-revalidate freshness] in seconds.
docstring_tokens: Returns [ freshness stale - while - revalidate freshness ] in seconds .
function: def GetFreshnessLifetimes(self):
      """Returns [freshness, stale-while-revalidate freshness] in seconds."""
      # This is adapted from GetFreshnessLifetimes() in
      # //net/http/http_response_headers.cc (which follows the RFC).
      r = self.request
      result = [0, 0]
      if (r.HasResponseHeaderValue('Cache-Control', 'no-cache')
          or r.HasResponseHeaderValue('Cache-Control', 'no-store')
          or r.HasResponseHeaderValue('Vary', '*')):  # RFC 2616, 13.6.
        return result
      must_revalidate = r.HasResponseHeaderValue(
          'Cache-Control', 'must-revalidate')
      swr_header = r.GetCacheControlDirective('stale-while-revalidate')
      if not must_revalidate and swr_header:
        result[1] = _ParseStringToInt(swr_header)
  
      max_age_header = r.GetCacheControlDirective('max-age')
      if max_age_header:
        result[0] = _ParseStringToInt(max_age_header)
        return result
  
      date = self._GetDateValue('Date') or self._response_time
      expires = self._GetDateValue('Expires')
      if expires:
        result[0] = expires - date
        return result
  
      if self.request.status in (200, 203, 206) and not must_revalidate:
        last_modified = self._GetDateValue('Last-Modified')
        if last_modified and last_modified < date:
          result[0] = (date - last_modified) / 10
          return result
  
      if self.request.status in (300, 301, 308, 410):
        return [2**48, 0] # ~forever.
      # No header -> not fresh.
      return result
function_tokens: def GetFreshnessLifetimes ( self ) : # This is adapted from GetFreshnessLifetimes() in # //net/http/http_response_headers.cc (which follows the RFC). r = self . request result = [ 0 , 0 ] if ( r . HasResponseHeaderValue ( 'Cache-Control' , 'no-cache' ) or r . HasResponseHeaderValue ( 'Cache-Control' , 'no-store' ) or r . HasResponseHeaderValue ( 'Vary' , '*' ) ) : # RFC 2616, 13.6. return result must_revalidate = r . HasResponseHeaderValue ( 'Cache-Control' , 'must-revalidate' ) swr_header = r . GetCacheControlDirective ( 'stale-while-revalidate' ) if not must_revalidate and swr_header : result [ 1 ] = _ParseStringToInt ( swr_header ) max_age_header = r . GetCacheControlDirective ( 'max-age' ) if max_age_header : result [ 0 ] = _ParseStringToInt ( max_age_header ) return result date = self . _GetDateValue ( 'Date' ) or self . _response_time expires = self . _GetDateValue ( 'Expires' ) if expires : result [ 0 ] = expires - date return result if self . request . status in ( 200 , 203 , 206 ) and not must_revalidate : last_modified = self . _GetDateValue ( 'Last-Modified' ) if last_modified and last_modified < date : result [ 0 ] = ( date - last_modified ) / 10 return result if self . request . status in ( 300 , 301 , 308 , 410 ) : return [ 2 ** 48 , 0 ] # ~forever. # No header -> not fresh. return result