title: How to cache query result in django?
body: <p>I am trying to cache query results on my django app. However, it seems that it is caching the whole app. I tried following logi:</p>
  
  <pre><code>def cacheView():
    result = cache.get('key')
    if result is None:
      result = Model.objects.get(id=1)
      cache.set('key', 'result')
  </code></pre>
  
  <p>I am calling this method when user logs in. However, if I try to logout after login, it keeps me on same page as if I am still logged in. I tried to follow the Django documentation on cache at <a href="http://docs.djangoproject.com/en/1.2/topics/cache/" rel="noreferrer">http://docs.djangoproject.com/en/1.2/topics/cache/</a> but to no success.</p>
  
  <p>Another thing I tried is that if I try to use the cache decorator just above the view as:</p>
  
  <pre><code>@cache_control(max_age=1000)
  def cacheView():
   ...
  </code></pre>
  
  <p>it does it gives an error saying "response header not defined". I am new to django and sure that I missed something. Any idea? </p>