I’m working on a paragraph type that will need to display on a very limited number of pages but has some specific functionality where the preprocess function will need to run each time.
In my preprocess function, I’ve tried various iterations of the following:
$variables['elements']['#cache']['max-age'] = '0'; $variables['elements']['#cache']['contexts'][] = 'url.path'; $variables['elements']['#cache']['contexts'][] = 'url.query_args:r'; $variables['elements']['#cache'] = ['tags' => ['my_paragraph']]; Cache::invalidateTags(['my_paragraph']); Drupal::service('page_cache_kill_switch')->trigger();
However, the preprocess function runs once after a cache clear and then doesn’t run again.
What am I doing incorrectly here? How can I get this to run each time?