One of the site has fairly large cachetags table at over 418K records. Is there a way to limit the size of this table.

This table is not cleared on cache clear.

Since Drupal 8.4 there has been a way to limit the size of cache tables, as noted in change record. However, these settings do not affect the size of cachetags table. I tried adding the following to the settings.php file, but these don't work.

$settings['database_cache_max_rows']['cachetags'] = 50000;
$settings['database_cache_max_rows']['bins']['cachetags'] = 50000;
  1. Is it safe to limit or purge the cachetags table?
  2. Is there a way to limit the size of cachetags table without resorting to manually truncating the table?

2 Answers 2


We just ended up writing a more general solution to purge PHP and Database cache's used by Drupal Core. This module provides three ways to truncate cachetags and other cache_* database tables via

  • Web browser user interface
  • Curl commands
  • Drush commands

The Cache Utility module is available on Drupal.org

With this module I can set a cron job to periodically purge the cachetags table to keep database sizes sane.


So it appears that Drupal core neither limits the size of cachetags table and not it provides a mechanism to limit it via a setting, like it offers for other cache bins.

Cachetags table is not cleared on cache reset, neither via web browser no via drush.

There is another issue noted in Drupal core that cachetags table can grow endlessly as has been the case that I have come across.

So a blunt method or periodically cleaning the cachetags need to be performed. Something like follows with drush or direct sql statement via mysql cli client or php-myadmin.

drush sqlq "TRUNCATE cachetags;" -l <uri> --no-interaction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.