Ticket #14737: move-cache-doc-comment.diff

File move-cache-doc-comment.diff, 1.6 KB (added by Adam Vandenberg, 13 years ago)
  • django/views/decorators/cache.py

    diff --git a/django/views/decorators/cache.py b/django/views/decorators/cache.py
    index bba7cd9..577c1dd 100644
    a b  
    1 """
    2 Decorator for views that tries getting the page from the cache and
    3 populates the cache if the page isn't in the cache yet.
    4 
    5 The cache is keyed by the URL and some data from the headers. Additionally
    6 there is the key prefix that is used to distinguish different cache areas
    7 in a multi-site setup. You could use the sites.get_current().domain, for
    8 example, as that is unique across a Django project.
    9 
    10 Additionally, all headers from the response's Vary header will be taken into
    11 account on caching -- just like the middleware does.
    12 """
    13 
    141try:
    152    from functools import wraps
    163except ImportError:
    from django.middleware.cache import CacheMiddleware  
    229
    2310
    2411def cache_page(*args, **kwargs):
     12    """
     13    Decorator for views that tries getting the page from the cache and
     14    populates the cache if the page isn't in the cache yet.
     15
     16    The cache is keyed by the URL and some data from the headers.
     17    Additionally there is the key prefix that is used to distinguish different
     18    cache areas in a multi-site setup. You could use the
     19    sites.get_current().domain, for example, as that is unique across a Django
     20    project.
     21
     22    Additionally, all headers from the response's Vary header will be taken
     23    into account on caching -- just like the middleware does.
     24    """
    2525    # We need backwards compatibility with code which spells it this way:
    2626    #   def my_view(): pass
    2727    #   my_view = cache_page(my_view, 123)
Back to Top