Created
April 9, 2012 04:33
-
-
Save nashibao/2341444 to your computer and use it in GitHub Desktop.
django cache key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _generate_cache_key(request, headerlist, key_prefix): | |
"""Returns a cache key from the headers given in the header list.""" | |
ctx = md5_constructor() | |
for header in headerlist: | |
value = request.META.get(header, None) | |
if value is not None: | |
ctx.update(value) | |
path = md5_constructor(iri_to_uri(request.path)) | |
cache_key = 'views.decorators.cache.cache_page.%s.%s.%s' % ( | |
key_prefix, path.hexdigest(), ctx.hexdigest()) | |
return _i18n_cache_key_suffix(request, cache_key) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment