How to exclude page frontmatter from being cached?

Setting cache_enable: false in a page header or frontmatter does seem to stop the content from being cached. The page is still present in the cache but it’s content is always refreshed when the page is requested. That is my understanding which may be wrong of course.

In my case with dynamic Twig processed frontmatter I need the full page uncached.

In other words I am looking for the same behaviour as when caching is disabled system wide. But then of course only for some pages.

Because this need is related to a new plugin I’m creating I think I could recache a page as explained by Andy Miller in Grav issue #810.
The problem is though, I don’t know and can’t figure out how to use that function from a custom plugin.

Anyone to the rescue please?

By adding the lines below to /system/src/Grav/Common/Page/Page.php#L620 the frontmatter is processed when system.pages.frontmatter.process_twig === true and page.header.cache_enable === false:

$frontmatter_process_twig = Grav::instance()['config']->get('system.pages.frontmatter.process_twig');

// process frontmatter if page is excluded from the cache 
if ($cache_enable === false && $frontmatter_process_twig === true) {
    $this->header = $content_obj['frontmatter'];
    $this->processFrontmatter();
}

This allows for dynamic frontmatter variables for example:

now: '{{ ''now''|date(''Y-m-d H:i:s'') }}'

The value of now can then be used in markdown (if page.header.process.twig is true) with:

The time is {{ header.now }}