def learn_cache_key(request, response, cache_timeout=None, key_prefix=None, cache=None):
 if (key_prefix is None):
  key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
 if (cache_timeout is None):
  cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
 cache_key = _generate_cache_header_key(key_prefix, request)
 if (cache is None):
  cache = get_cache(settings.CACHE_MIDDLEWARE_ALIAS)
 if response.has_header('Vary'):
  headerlist = [('HTTP_' + header.upper().replace('-', '_')) for header in cc_delim_re.split(response['Vary'])]
  cache.set(cache_key, headerlist, cache_timeout)
  return _generate_cache_key(request, request.method, headerlist, key_prefix)
 else:
  cache.set(cache_key, [], cache_timeout)
  return _generate_cache_key(request, request.method, [], key_prefix)

def learn_cache_key ( request , response , cache_timeout = None , key_prefix = None , cache = None ) : if ( key_prefix is None ) : key_prefix = settings . CACHE_MIDDLEWARE_KEY_PREFIX if ( cache_timeout is None ) : cache_timeout = settings . CACHE_MIDDLEWARE_SECONDS cache_key = _generate_cache_header_key ( key_prefix , request ) if ( cache is None ) : cache = get_cache ( settings . CACHE_MIDDLEWARE_ALIAS ) if response . has_header ( 'Vary' ) : headerlist = [ ( 'HTTP_' + header . upper ( ) . replace ( '-' , '_' ) ) for header in cc_delim_re . split ( response [ 'Vary' ] ) ] cache . set ( cache_key , headerlist , cache_timeout ) return _generate_cache_key ( request , request . method , headerlist , key_prefix ) else : cache . set ( cache_key , [ ] , cache_timeout ) return _generate_cache_key ( request , request . method , [ ] , key_prefix )
learns what headers to take into account for some request path from the response object .