Clearing the Cache

Clearing the cache is a common task when managing a Drupal site, as it ensures that your site displays the most up-to-date content and functionality. This guide will walk you through different methods to clear and rebuild the cache using both the Drupal administrative interface and the command line tool, Drush.

Goal

By the end of this guide, you will be able to:

  • Clear and rebuild the cache using the Drupal administrative interface.
  • Use the rebuild script to clear and rebuild the cache.
  • Use Drush to clear and rebuild the cache.

Prerequisites

  • A Drupal site up and running.
  • Access to the server where the Drupal site is hosted.
  • Administrative privileges for the Drupal site.

Clearing and Rebuilding Cache

Using the Drupal Administrative Interface

  1. Log in to your Drupal site as an administrator.
  2. Navigate to the Performance section.
    • Click on Configuration in the main menu.
    • Select Development and then Performance.
  3. Clear the cache.
    • Click on the Clear all caches button at the top of the page.
    • Confirm the action by clicking Yes.

Using the Rebuild Script

The rebuild script provides a quick way to clear and rebuild the cache programmatically.

  1. Edit the settings.php file.
    • Locate the settings.php file in your Drupal installation, typically located at /sites/default/settings.php.
    • Open the file in a plain text editor.
    • Add the following line to the end of the file and save the changes:
      $settings['rebuild_access'] = TRUE;
      
  2. Run the rebuild script.
    • Open your web browser and navigate to http://www.example.com/core/rebuild.php (replace www.example.com with your actual domain).
    • After a short pause, you should be redirected to the home page of your site, and the cache should be rebuilt.
  3. Remove the line from settings.php.
    • Open the settings.php file again.
    • Find the line you added with $settings['rebuild_access'].
    • Remove this line and save the file.

Using Drush

Drush is a command-line shell and scripting interface for Drupal. It provides a wide range of commands to manage your Drupal site.

  1. Install Drush if it is not already installed.
  2. Clear the cache using Drush.
    • Open your terminal or command prompt.
    • Run the following command to clear all caches:
      drush cache:rebuild
      
    • You should see the output message “Cache rebuild complete.”
  3. Clear a specific cache type using Drush.
    • Run the following command to clear a specific cache type, for example, the render cache:
      drush cache:clear render
      

Videos

Additional Resources

Attributions

This guide is adapted and edited by Joe Shindelar and Jack Haas from Clearing or Rebuilding Drupal’s Cache, copyright 2000-2025 by the individual contributors to the Drupal Community Documentation.


Note: Always ensure you have backups of your site before performing cache operations, especially if you are not familiar with the process.