Dmitry Belaventsev
Dmitry Belaventsev

Reputation: 6657

Deliver cached page to anonymous user and non-cache to authorized

I'm using django 1.3 in my app. I need to organize caching, which satisfies following rules:

  1. using memcached as cache backend
  2. using @cache_page decorator in views, which I want to cache
  3. each non-authorized (anonymous) user sees cached version of the page (so django should deliver cached version of the page);
  4. for each authorized user django should generate new version of page (non-cached) and deliver it.

How I can do it? I tried using two decorators below the view:

@cache_page(108000)
@vary_on_cookie

but when I logged in, first I see the new data, when after updating the data (directly in database by using phpMyAdmin) I refresh the page and see previous content version.

Upvotes: 1

Views: 555

Answers (1)

Related Questions