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
- Log in to your Drupal site as an administrator.
- Navigate to the
Performancesection.- Click on
Configurationin the main menu. - Select
Developmentand thenPerformance.
- Click on
- Clear the cache.
- Click on the
Clear all cachesbutton at the top of the page. - Confirm the action by clicking
Yes.
- Click on the
Using the Rebuild Script
The rebuild script provides a quick way to clear and rebuild the cache programmatically.
- Edit the
settings.phpfile.- Locate the
settings.phpfile 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;
- Locate the
- Run the rebuild script.
- Open your web browser and navigate to
http://www.example.com/core/rebuild.php(replacewww.example.comwith your actual domain). - After a short pause, you should be redirected to the home page of your site, and the cache should be rebuilt.
- Open your web browser and navigate to
- Remove the line from
settings.php.- Open the
settings.phpfile again. - Find the line you added with
$settings['rebuild_access']. - Remove this line and save the file.
- Open the
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.
- Install Drush if it is not already installed.
- Follow the instructions on the Drush installation page to install Drush.
- 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.”
- 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
- Run the following command to clear a specific cache type, for example, the render cache:
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.