[Drupal] Methods to clear Drupal caches

| | 1 min read

Here I am listing some methods to clear Drupal caches. Drupal caching is done to improve and enhance overall performances of the site. Its always recommended to enable the page caching and block caching in Drupal.

  • The simplest way to clear the Drupal cache is to go to Administration > Configuration > Development > Performance
  • Click Clear caches.
  • Using drush through terminal. Run the command drush cc all in terminal.
  • Flush cache tables from the database. Log into your PHPMyAdmin select your cache_ tables and flush/empty them.
  • Using drupal_flush_all_caches(), to clear all caches. Add the code to index.php.
  • If you can access your Drupal files but are unable to access your admin page, Then you can't clear caches directly. Even after doing necessary modifications, you may not see any improvement to your site since your pages are still cached in such situation an easy way to clear the cache is to use the PHP function in your index file and clear caches:
    require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    drupal_flush_all_caches();
    //menu_execute_active_handler();

Hope this is helpful for you. Do you have any doubts, please share with us. For drush related articles, please use your time using this link.