Possibility to turn off the cache

Furthermore it is necessary to be able to turn off the cache when a user is logged in, and it thereby additional content is displayed (Protecting parts of a page), which is not visible to unregistered users.
The same page should be delivered to unregistered users without this additional content from the cache.

I think is not possible with the cache system because for the max performance the cache system save the current html page into json object.

If you have some pages with protected area the best way is use the configuration key cache.ignore and setup this variable. For ignore single page you can setup with this example.

c::set('cache.ignore', [
    'example'
]);

If you have example a blog pages you can setup:

c::set('cache.ignore', [
    'blog/*'
]);

if the blog/ it’s your blog route.

It’s very powerfull option, I used for post forms and working great.

My wish is to have an option in the PHP code of a page, which tells the cache to not save this page.
If this option is not set in this page (e.g. for a guest), then this page should be cached.
This is the same page, but viewed by two different persons or roles.

And if this cached page is viewed again, then this option in the PHP code of the page shoud tell Kirby to call the cache or to render the page live.

I assume you refer to the templates when you refer to “code of a page”? If so, this seems simply not possible given the current architecture of Kirby.

I have a possible workaround here - but would still need a change to Kirby. Basically an extension of this suggestion to make it more flexible - if routes were parsed before the cache, you could use them to return a different page for logged in users (and do other things)

http://forum.getkirby.com/t/kirby-cache-routes/2032