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:
or use the shorter version
3. Custom PHP Code
Insert the following PHP code snippet:
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.