[Django]-Django view based cache with authed users

0👍

You may simply use client-based caching with cache_control. Like:

@cache_control(max_age=60 * 5)
def view(request):

0👍

There’s a snippet here that uses the Django cache framework. I think you can modify it for yourself. There’s line 38:

key = make_cache_key(request.get_full_path(), getattr(request, 'supports_html5', None))

You can change it to

key = make_cache_key(request.user[.id], request.get_full_path(), getattr(request, 'supports_html5', None))

So that users have different page keys.

Leave a comment