Extensive site caching with Django - problems with password protected pages when logging out

I recently used sitewide caching using memcached in my Django application, I set TTL to 500 seconds and implement other parts of the web application on each viewing cache.

The problem is that when the user logs out because this is a form message, the behavior of the site behaves as expected, however, if they then go to the password-protected part of the site, the application behaves as if they were still logged in into the system, unless they are "updated." I am new to caching and wondering if I can do anything smart to prevent this?

+5
source share
2 answers

I ran into similar problems. The standard way for Django is to disable the cache for authenticated users.

#settings.py
CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True

It works great if different users see different pages (for example, their username on them), and you cannot have one version for them.

But if there are only 2 versions of the page: for authenticated users and for others, then it is not good to completely disable the cache for authenticated users. I wrote an application that, among other things, allows you to fine-tune the cache in this case.

Update

: , "", . , ( Expires E-tag), .

( , URL-), @cache_control(must_revalidate=True) decorator.

+7

All Articles