          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 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:
 
</s> remove 
        cache_kwargs = {}
        try:
            key_prefix = kwargs.get('key_prefix')
            if key_prefix is not None:
                cache_kwargs['KEY_PREFIX'] = key_prefix
        except KeyError:
            cache_kwargs['KEY_PREFIX'] = settings.CACHE_MIDDLEWARE_KEY_PREFIX
 </s> add             if cache_timeout is None:
                cache_kwargs['TIMEOUT'] = settings.CACHE_MIDDLEWARE_SECONDS
            else:
                cache_kwargs['TIMEOUT'] = cache_timeout </s> remove def learn_cache_key(request, response, cache_timeout=None, key_prefix=None):
 </s> add def learn_cache_key(request, response, cache_timeout=None, key_prefix=None, cache=None):
    if cache is None:
        cache = get_cache(settings.CACHE_MIDDLEWARE_ALIAS)
          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:
keep keep keep add keep keep keep keep keep keep
 Beefed up the tests for multi-cache handling of the cache middleware and view decorators, and made a couple of tweaks for edge cases as a result.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@15021 bcc190cf-cafb-0310-a4f2-bffc1f526a37 
django/utils/cache.py