MCPcopy
hub / github.com/django/django / cache_page

Function cache_page

django/views/decorators/cache.py:9–27  ·  view source on GitHub ↗

Decorator for views that tries getting the page from the cache and populates the cache if the page isn't in the cache yet. The cache is keyed by the URL and some data from the headers. Additionally there is the key prefix that is used to distinguish different cache areas in a m

(timeout, *, cache=None, key_prefix=None)

Source from the content-addressed store, hash-verified

7
8
9def cache_page(timeout, *, cache=None, key_prefix=None):
10 """
11 Decorator for views that tries getting the page from the cache and
12 populates the cache if the page isn't in the cache yet.
13
14 The cache is keyed by the URL and some data from the headers.
15 Additionally there is the key prefix that is used to distinguish different
16 cache areas in a multi-site setup. You could use the
17 get_current_site().domain, for example, as that is unique across a Django
18 project.
19
20 Additionally, all headers from the response's Vary header will be taken
21 into account on caching -- just like the middleware does.
22 """
23 return decorator_from_middleware_with_args(CacheMiddleware)(
24 page_timeout=timeout,
25 cache_alias=cache,
26 key_prefix=key_prefix,
27 )
28
29
30def _check_request(request, decorator_name):

Used in the wild real call sites across dependent graphs

searching dependent graphs…