Ticket #10016: 10016-cache-middleware-handle-long-urls.diff

File 10016-cache-middleware-handle-long-urls.diff, 1.7 KB (added by Timothée Peignier, 16 years ago)
  • django/utils/cache.py

     
    143143        value = request.META.get(header, None)
    144144        if value is not None:
    145145            ctx.update(value)
     146    path = md5_constructor()
     147    path.update(iri_to_uri(request.path))
    146148    return 'views.decorators.cache.cache_page.%s.%s.%s' % (
    147                key_prefix, iri_to_uri(request.path), ctx.hexdigest())
     149               key_prefix, path.hexdigest(), ctx.hexdigest())
    148150
    149151def get_cache_key(request, key_prefix=None):
    150152    """
     
    158160    """
    159161    if key_prefix is None:
    160162        key_prefix = settings.CACHE_MIDDLEWARE_KEY_PREFIX
     163    path = md5_constructor()
     164    path.update(iri_to_uri(request.path))
    161165    cache_key = 'views.decorators.cache.cache_header.%s.%s' % (
    162                     key_prefix, iri_to_uri(request.path))
     166                    key_prefix, path.hexdigest())
    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
     190    path = md5_constructor()
     191    path.update(iri_to_uri(request.path))
    186192    cache_key = 'views.decorators.cache.cache_header.%s.%s' % (
    187                     key_prefix, iri_to_uri(request.path))
     193                    key_prefix, path.hexdigest())
    188194    if response.has_header('Vary'):
    189195        headerlist = ['HTTP_'+header.upper().replace('-', '_')
    190196                      for header in cc_delim_re.split(response['Vary'])]
Back to Top