Changing configuration using form I have created a form using which I want to make changes in the configuration.Currently I am submitting form doing something like this:

 public function submitForm(array &amp;$form, FormStateInterface $form_state) {
  \Drupal::service('config.factory')
    -&gt;getEditable('module.settings')
    -&gt;set('module_entities', $form_state-&gt;getValue('module_entities'))
    -&gt;save();
 }


But the problem is when I have submitted the form changes in the configuration are not reflected.But when I clear the cache after submitting the form the changes are reflected.what changes should I make so that when user submits form the changes are reflected thereafter?

Update: I tried to find my mistake and found out that configuration is getting updated but somehow the changes getting lost and not being reflected in the block which I have created. In the block creation code I am creating blocks for different entities depending on the entities present in the configuration.But the configuration is not showing correct values so block for required entities is not being created.Surprisingly when I clear cache the code works(which means configuration becomes updated).Does this mean for block creation I need to clear cache?
I am currently using this code:

 `public function getDerivativeDefinitions($base_plugin_definition) {
   $this-&gt;derivatives[$entity_type] = $base_plugin_definition;
   $this-&gt;derivatives[$entity_type]['admin_label'] .= ' (' . $entity_definition-&gt;getLabel() .')';
   $this-&gt;derivatives[$entity_type]['cache'] = ?;


}`

What should I add over here to make block depend on configuration without clearing cache?
In the plugin I am returning:

public function build() {
return array(
  '#theme' =&gt; 'links__entity__module',
  '#links' =&gt; $this-&gt;linkBuilder-&gt;buildLinks($this-&gt;request-&gt;attributes-&gt;get($entity_type)),
      ); 
}
Blocks are cached by default.

You don't need to manually clear those caches when you change your configuration, but you need to flag/tag your blocks output to tell Drupal that your block output depends on your configuration.

Read the Cacheability documentation. What you need is something like this:

$output['#cache']['tags'] = $config-&gt;getCacheTags();