Skip to content

Instantly share code, notes, and snippets.

@lvidarte
Created September 3, 2010 20:56
Show Gist options
  • Save lvidarte/564547 to your computer and use it in GitHub Desktop.
Save lvidarte/564547 to your computer and use it in GitHub Desktop.
Django cache_timeout decorator
def cache_timeout(timeout):
def cache(view):
def deco(*args, **kwargs):
response = view(*args, **kwargs)
response.cache_timeout = timeout
return response
return deco
return cache
# #Example
# @cache_timeout(60*60)
# def index(request):
# title = "Hello world"
# return render_to_response('index.html', locals())
# #index = cache_timeout(60*60)(index)(request)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment