Invalidate cache on ConfigFormBase submit I have a ConfigFormBase called TextConfiguration where I have defined several fields for the address, phone number, etc...

These variables are shown in the contact form on my website. When I modify them and enter as anonymous in /contact, the value is not updated.

I've tried this in my ConfigFormBase form submit, but it does not work.

// Additionally, clear cache to prevent mismatch data.
$tags = $this-&gt;config(static::COMPET_SETTINGS)-&gt;getCacheTags();
if ($tags) {
  Cache::invalidateTags($tags);
}


I'm doing something wrong? I need to configure or do something to get it to update the data when a value is changed? Thanks all!

Edit: Example of how I'm rendering the fields.
You have to add the cache tags to the rendered output of the config field:

$form['example'] = [
  '#markup' =&gt; $settings-&gt;get('name'),
  '#cache' =&gt; [
    'tags' =&gt; $settings-&gt;getCacheTags(),
  ],
];