Emptying the cache in Drupal is an important maintenance task, especially when you've made changes that are not yet visible on the site. Clearing the cache ensures that the changes take effect immediately and helps in debugging issues.Â
1. Via Admin UI
- Log in to Admin Account
- Go to Administration > Configuration > Development > Performance.
- Click the Clear all caches button at the top of the page.
2. Using Drush
If you have Drush installed, cache clearing becomes a simple command-line task.
- Open Terminal
- Navigate to Drupal Root: Use cd to navigate to the Drupal root directory.
-
Execute the following Drush command:
 drush cache:rebuild  Â
or use the shorter version
  drush cr  Â
3. Custom PHP Code
Insert the following PHP code snippet:
Â
  \Drupal::service('page_cache_kill_switch')->trigger();  Â
or  drupal_flush_all_caches();  Â
Â
4. Via Database
This is the least recommended method and should only be used when other methods are not feasible.
- Access Database: Use a database management tool like phpMyAdmin.
- Find tables that start with cache_.
- Empty Tables: Select these tables and empty them.
Clearing cache too often may affect performance. It's advisable to do it only when necessary.