How to Clear Cache in Drupal

1 minute read

Clearing the cache in a Drupal site is a common task frequently needed for changes to code in themes and modules.

Caches can be cleared as a whole, or individually. The individual method is more advanced, used to clear an individual cache, and must be done from the command line, database, or through the help of a contributed module.

Several ways to clear the cached data in Drupal are listed below, starting with the simpler, and then moving to more advanced methods.

Admin Interface

The steps are very similar for both Drupal 7 and 8.  In the menu, go to Configuration -> Development -> Performance. In the URL, the path is /admin/config/development/performance.

As in the images below, click on the “Clear all caches” button.

Drupal 7

 

Drupal 8

 

Drush

To clear all the cache use the following commands.

Drupal 7

drush cache-clear all

To select from a list of caches to clear. You will be prompted with a list of individual caches and to select the number of which one you would like to clear.

drush cache-clear

Drupal 8

drush cache-rebuild

Database

To clear the cache in the database, use your favorite SQL editor.

Drupal 7

Truncate the “cache” table and any tables matching the pattern “cache_*”.

Drupal 8

Truncate the tables matching the pattern “cache_*”.