1

I want to use Memcache in my django application. Ι want to be able to use cache per view. But I hanvent understood something in caching. Lets say I have the following view

def view(request, customer_id):
    #some view functionality here

    return queryset #which my different according to some posting data

Suppose I cache this view

@cache_page(60*15)
def view(request, customer_id):
    #some view functionality here

    return queryset

According to this if a user visits my page associated to the "view" it will be cached and then retrieved from cache. What would be cached? The queryset? or the template? But what about the queryset that could be different according to some post data(e.g a search view)? Could you be a little bit more explanatory on how to use cache for querysets? Should I cache querysets that change a lot? Or not?

Apostolos
  • 7,763
  • 17
  • 80
  • 150

1 Answers1

2
  1. The whole page will be cached.
  2. Cache uses whole url as the key. So url?q=aaa' and 'url?q=bbb will be cached as different pages.
  3. Only GET and HEAD requests are cached. So your POST request will work as usual.

As for caching of querysets... Read this answer

Community
  • 1
  • 1
catavaran
  • 44,703
  • 8
  • 98
  • 85