I have a view which I want to cache only for unauthenticated users. The view should be something like this:
@cache_page_for_guests(60 * 15)
def my_view(request):
I've looked at the docs but could not but could not find any hints about this.
Actually my question is exactly as this, which is unanswered, and I could not make sense of the comments.
So appreciate your help.
you can use
cache_page_for_guest
just likecache_page
. It'll accept the same arguments as ofcache_page
. Based on the user's authentication, it'll show either a normal view or a cached view.Write a custom decorator like this:
Then in view