I would like to hide or show parts of a page depending on whether a user is logged in or not. Based on what rhukster suggests in Hiding parts of pages I use something like:
---twig
{% if grav.user.authorize('site.login') %}
This is text only logged users can see.
{% endif %}
This works fine when caching is disabled. However when caching is enabled it does not work. The previously cached page content gets output even though `process: twig: true` is set in the page header. This is the front matter for the (modular) page:
---yaml
title: live
published: true
process:
twig: true
markdown: false
routable: false
cache_enable: true
visible: false
The crude way is to disable caching completely but I keep hoping to find a way to serve cached content to non logged in users (anonymous visitors) for performance reasons.
Again any help is much appreciated!