remove cache in hook_preprocess_node I'm using hook_preprocess_node to get node field and make some processes, then pass a variable to the node to use it in the node twig template. The problem with me that when I edit this node, it doesn't affect on the view, I have to clear cache to see this change on the node view.

function THEME_preprocess_node(&amp;$variables) {

    if (isset($variables['elements']['#node'])) {
        $node = $variables['elements']['#node'];
        $bundle = $node-&gt;bundle();
    }
    if (isset($bundle) &amp;&amp; $bundle == 'crse') {
        $course_schedules = array();
        foreach ($node-&gt;get('crse_sched') as $schedule_item) {
            $schedule_entity = \Drupal\node\Entity\Node::load($schedule_item-&gt;target_id);
            $schedule = new stdClass();
            $schedule-&gt;title = $schedule_entity-&gt;get('title')-&gt;getValue()[0]['value'];
            $schedule-&gt;seats = $schedule_entity-&gt;get('seats')-&gt;getValue()[0]['value'];
            $schedule-&gt;state = $schedule_entity-&gt;get('moderation_state')-&gt;getValue()[0]['value'];
            $course_schedules[] = $schedule;
        }
        $variables['schedules'] = $course_schedules;
    }
}
You have to add cache tags of all entities you get data from. Add this line to the foreach loop:

$variables['#cache']['tags'][] = 'node:' . $schedule_entity-&gt;id();


The parent node is already tagged, which would also happen for the schedule entities if rendered normally.

This is all you need to do, adding the tags of the entities you use to build the rendered output. The entity system invalidates cache items, which are tagged correctly, automatically on all CRUD operations.