Ticket #10387: 10387.diff

File 10387.diff, 1.6 KB (added by Matt Boersma, 16 years ago)

Same patch, renamed with our preferred .diff extension

  • django/utils/cache.py

     
    146146    return 'views.decorators.cache.cache_page.%s.%s.%s' % (
    147147               key_prefix, iri_to_uri(request.path), ctx.hexdigest())
    148148
     149def _generate_cache_header_key(key_prefix, request):
     150    """Returns a cache key for the header cache."""
     151    return 'views.decorators.cache.cache_header.%s.%s' % (
     152        key_prefix, iri_to_uri(request.path))
     153
    149154def get_cache_key(request, key_prefix=None):
    150155    """
    151156    Returns a cache key based on the request path. It can be used in the
     
    158163    """
    159164    if key_prefix is None:
    160165        key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
    161     cache_key = 'views.decorators.cache.cache_header.%s.%s' % (
    162                     key_prefix, iri_to_uri(request.path))
     166    cache_key = _generate_cache_header_key(key_prefix, request)
    163167    headerlist = cache.get(cache_key, None)
    164168    if headerlist is not None:
    165169        return _generate_cache_key(request, headerlist, key_prefix)
     
    183187        key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
    184188    if cache_timeout is None:
    185189        cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS
    186     cache_key = 'views.decorators.cache.cache_header.%s.%s' % (
    187                     key_prefix, iri_to_uri(request.path))
     190    cache_key = _generate_cache_header_key(key_prefix, request)
    188191    if response.has_header('Vary'):
    189192        headerlist = ['HTTP_'+header.upper().replace('-', '_')
    190193                      for header in cc_delim_re.split(response['Vary'])]
Back to Top