Rebuilding cache in Console or Drush

Drupal utilizes caching to store plugin definitions, routes, and so on. When you add a new plugin definition or new route, you need to rebuild Drupal's cache for it to be recognized.

In this recipe, we will walk you through using both Drush and Console to clear various cache bins in Drupal. It is important to know how to clear specific cache bins so that you do not need to rebuild everything, if possible.

How to do it…

  1. Open a terminal and navigate to an installed Drupal directory.
  2. We use the cache-rebuild command in Drush to rebuild all of Drupal's caches, including routes:
    $ drush cache-rebuild
    Cache rebuild complete. 
    
  3. Drush will bootstrap Drupal to a full site and invoke a full cache clear.
  4. In Console, we use the ...

Get Drupal 8: Enterprise Web Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.