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-rebuild drush rebuild or drush cr
2. Via Admin
On the Drupal site, Navigate to
Administration > Configuration > Development > Performance. Click the button
Clear all Caches.
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.
$settings['rebuild_access'] = TRUE; in your
settings.php, and visit
Run script in your command line
/core/scripts/rebuild_token_calculator.sh, then use the results there as query parameters for
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.
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.