diff --git a/css_editor.module b/css_editor.module
index 313e67e465c6c1acab5db078cc37408211ccf588..1a9f921bef0c17d04299d0649c4ce59fb917d847 100644
--- a/css_editor.module
+++ b/css_editor.module
@@ -116,8 +116,8 @@ function _css_editor_theme_settings_form_submit($form, FormStateInterface $form_
       ->set('css', $form_state->getValue(['css_editor', 'css']))
       ->set('path', $file)
       ->save();
-    // Clear cache.
-    drupal_flush_all_caches();
+    // Invalidate the libraries cache.
+    \Drupal::service('cache_tags.invalidator')->invalidateTags(['library_info']);
   }
   // Remove the settings from the form state so the values are not saved in the
   // theme settings.