title: Problems using both pageview counter and cache in django
body: <p>I'm creating a django app for comics and having a code in my views.py of an app like this:</p>
  
  <pre><code>@comic_inc
  @cache_page(settings.CACHE_S) //CACHE_S = 60
  @vary_on_cookie
  def comic(request, com):
      try:
          cobj = Comic.gen_comic(com, request.user.id)
          if request.GET.get('sort') == '2':
              chaps = Chapter.objects.filter(published=True, comic = cobj).order_by('num','snum','volume')
          else:
              chaps = Chapter.objects.filter(published=True, comic = cobj).order_by('-num','-snum','-volume')
          return render(request, 'base/comic.html', {'comic': cobj, 'chapters':chaps})
      except Exception as e:
          return render(request, 'base/comic.html', {'error': 'Comic not found'})
  </code></pre>
  
  <p>the <code>@comic_inc</code> is a decorator I created when I was trying to implement this solution: <a href="https://stackoverflow.com/questions/35208763/counting-page-views-or-hits-when-using-cache">Counting &quot;page views&quot; or &quot;hits&quot; when using cache</a></p>
  
  <p>the decorator code is as below:</p>
  
  <pre><code>def comic_inc(view_func):
      def _wrapped(*args,**kwargs):
          Comic.objects.filter(slug=kwargs.get('com')).update(pageviews=F('pageviews')+1)
          return view_func(*args,**kwargs)
      return _wrapped
  </code></pre>
  
  <p>I didn't particularly specify any <code>CACHE</code> in django settings since there is already a default cache <strong>django.core.cache.backends.locmem.LocMemCache</strong> that works perfectly fine for development (shows up properly in debug toolbar). Additionally I did try memcached (downloaded and ran <code>memcached -m 512 -vvv</code> in CMD and it worked perfectly).</p>
  
  <p>Either way the result was the same, the pageviews is updated only when cached page times out and only increased by 1. I don't mind that the view value is not changed for every refresh on the cached template page but I atleast want the value to be increased on the backend. I did verify if the value of pageviews is changing by refereshing about 20 times on the template and then checking the admin panel and also waiting for timeout and refreshing again, but the value didn't increase more than 1.</p>
  
  <p>Please help me.</p>