I am trying to cache a view unless the user is logged in.
return 'stuff to return'
Wrap the call in a
lambda. Flask-Cache will call the function when the view is executed, rather than once when the view is defined.
@app.cache.cached(timeout=300, unless=lambda: current_user.is_authenticated)
The docs specifically say that
unless should be a callable that will be executed each time.