I solved it by overriding cache() in App\Common.php.
If the user is logged in and the user is not under the admin section it should use the dummy handler. They will then never get cache response. The reason for checking if the first URI segment is admin is that I need to clean the cache when an admin edit a page. If it clears the dummy cache nothing happens. It will clean the whole cache which is not optimal but it's ok for me right now.
PHP Code:
if (! function_exists('cache')) {
function cache(string $key = null)
{
$session = Services::session();
$urlSegments = current_url(true)->getSegments();
$useDummyCache = $session->logged_in && !in_array('admin', current_url(true)->getSegments());
// Avoid cached responses if logged in
$cacheConfig = new Cache();
$cacheConfig->handler = $useDummyCache ? 'dummy' : $cacheConfig->handler;
$cache = Services::cache($cacheConfig);
// No params - return cache object
if (is_null($key)) {
return $cache;
}
// Still here? Retrieve the value.
return $cache->get($key);
}
}