Clear Django view cache on logout -


i'm cacheing view below:

@cache_page(60 * 15) def my_view(request):     # results request.user     return httpresponse(json.dumps(results), content_type="application/json", status=200) 

how can clear cache when user logs out?

you'll need define better cache key, changes on user or on user.is_authenticated. use key prefix if use redis redis allows removing keys stating prefix.

key = "result_{}".format(request.user.pk) results = cache.get(key) if not results:     results = ...     cache.set(key, results) ... 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -