Drupal Cache Clear & Cache Rebuild

Drupal Cache Clear & Cache Rebuild

On31st Jul 2021, 2024-11-22T08:18:21+05:30 ByKarthik Kumar D K | read
Listen Pause Resume Stop

In order to render a page via Drupal, Drupal will need to make several database queries and get the data to render. This process of making queries can be reduced by storing the web pages in a cache, which is what Drupal does.

And developers during developments may use this cache clear or cache rebuild quite often, like after installing a new module or theme. The site would slow for a couple of clicks but would be quick once the caches are filled back.

Coming to the article's agenda, Why there is Cache Rebuild on Drupal 8, while we had Cache Clear in Drupal 7.

Since Drupal is using caching very intensively and by this it creates lots of inter-dependencies. And for this clearing parts of the entire caches would lead to some major risks for a website. Here’s the Cache Rebuild will come and practically will rebuild (re-bootstraps) the whole Drupal site and will make sure that caches are perfectly cleared without any errors.

Drupal 8's cache-rebuild is one more step in the conventional cache-clear practice, it adds a new "re-bootstrapping" operation to the "cache clearing" process.

And how do you rebuild your caches in Drupal 8?

  • Via Drush
  • Via Admin side
  • Via /core/rebuild.php
  • Via Truncating all "cache_*" tables

1. Via Drush

If you have drush installed you will have the following commands for cache rebuild

drush cache-rebuilddrush rebuild or drush cr

2. Via Admin

On the Drupal site, Navigate to Administration > Configuration > Development > Performance. Click the button Clear all Caches.

3. Via /core/rebuild.php

Drupal 8 comes with a new /core/rebuild.php, which does the cache rebuild. This actually Rebuilds all Drupal caches even when Drupal itself does not work.

Add $settings['rebuild_access'] = TRUE; in your settings.php and visit BASE_URL/rebuild.php

Run script in your command line /core/admin/rebuild_token_calculator.sh, then use the results there as query parameters for /core/rebuild.php

Here's the source of Rebuild Script in Drupal (https://www.drupal.org/node/2153725)

4. Via Truncating all "cache_*" tables

Another approach is to empty all the data from the cache table from Drupal.

TRUNCATE cache_config

Similarly for all the cache_* tables.

To summarise, Drupal 8's cache-rebuild is one more step in the conventional cache-clear practice, it adds a new re-bootstrapping operation to the cache clearing process.

Related Articles

Recent Articles

Recent Quick Read

Recent Great People

We Need Your Consent
By clicking “Accept Cookies”, you agree to the storing of cookies on your device to enhance your site navigation experience.
I Accept Cookies