Checking Django Caching

How can I confirm that my Django views are cached when I use the cache_page decorator as follows:

@cache_page(60)
def my_view(request):

Ideally, I would like to display messages about deleting / skipping the cache in the console, so I can confirm that my view is cached for 60 seconds, etc.

Thanks a lot g

+7
source share
4 answers

you could take a copy django-debug-toolbar( http://github.com/robhudson/django-debug-toolbar ) and look at the requests: if the page is not pulled from the cache, it django-debug-toolbarshould display all the requests necessary to build your page. if the page is pulled out of the cache, you will not see requests.

, django-debug-toolbar "logging". heres , : http://gist.github.com/242011

django-memcache-status (http://github.com/bartTC/django-memcache-status) memcache-top (http://code.google.com/p/memcache-top/), memcache.

+5

process_request , ( django/middleware/cache.py)

131  response = cache.get(cache_key, None)
132  if response is None:
133      ...

...      logging.debug("Cache miss")
...
...  else:
...      logging.debug("Cache hit")

. , .

+1

, , HTTP.

$ curl -v http://localhost:8000/cached_view/ >/dev/null
[...]
< Cache-Control: max-age=900
< Expires: Tue, 02 Jul 2019 18:36:34 GMT
[...]

Cache-Control Expires , .

0

[] [] [] [] [] []]] [] [] [] = [] = [] [] = [] [] [] = [] [] [] [[B]]]] [ ] [] [] [[[L]]] [] []]] [] [] [] [[[0]]] [] [] [] [[[[© ™]]] [] [] [] [[[® ™]]] [] [] [] [[[]]] [] [] [] [[[]]] [] [] [] = [] [] [] [[[ = JAMANS = LAPUT = BAESA = ]]] [] [] [] = [] [] [] [[[(1 = = 0 = zer0 = 1)]]] [] [] [] [[ [[Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [ ] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E ] [N] [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N] [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [] [] [] [] [ ] []]] [] [] [] = [] = [] [] = [] [] [] = [] [] [] [[]]]] [] [] [] [[[]] ] [] []]] [] [] [] [[[]]] [] [] [] [[[[]]] [] [] [] [[[]]] [] [] [] [[[]]] [] [] [] [[[]]] [] [] [] = [[[[Δ] [] [Δ] [] = [😎] = [Δ] [ ] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [ 😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [ N], [Δ] [] [Δ] [ ] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [] [] [] [] [] []]] [] [] [] = [] = [] [] = [] [] [] = [] [] [] [[ B]]]] [] [] [] [[[L]]] [] []]] [] [] [] [[[0]]] [] [] [] [[[[© ™] ]] [] [] [] [[[® ™]]] [] [] [] [[[]]] [] [] [] [[[]]] [] [] [] = [] [ ] [] [[[ = JAMANS = LAPUT = BAESA = ]]] [] [] [] = [] [] [] [[[(1 = = 0 = zer0 = 1)]]] [] [] [] [[[[Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N] [Δ] [] [Δ] [N] = [ 😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [ N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N ] = [😎] = [Δ] [] [E] [N], [Δ] [] [Δ] [N] = [😎] = [Δ] [] [E] [N], [] [ ] [] [] [] []]] [] [] [] = [] = [] [] = [] [] [] = [] [] [] [[]]]] [] [] [ ] [[[]]] [] []]] [] [] [] [[[]]] [] [] [] [[[[]]] [] [] [] [[[]]] [] [] [] [[[]]] [] [] [] [[[]]] [] [] []

-3
source

All Articles