Change - Clearing Cache

Created on Dec. 17, 2012, 7:04 p.m. by Hevok & updated on Dec. 18, 2012, 9:42 a.m. by Hevok

For example to avoid that after logout the back button from the browser redirects to the previous page (it should redirect to the login page), the browser cache can be cleared by the following: ¶
¶
.. sourcecode:: python ¶
¶
... ¶
from django.views.decorators.cache import cache_control ¶
... ¶
@cache_control(no_cache=True, must_revalidate=True, no_store=True): ¶
def view(request): ¶
... ¶
¶
However,
this means that all views need to be wrapped in that structure, and that none of those views will be catchable. ¶
¶
An alternative is to consider using @vary_on_cookie, which means that the cache will be specific to that user only for the current cookie value. A "logout" will clear the session cookies and thus renders the cache invalid.


Comment: Added caveat and alternative.

Comment on This Data Unit