Loading...


Related Products


Date Published: February 5, 2025

Managing Large Cache Render tables in Drupal 8

Issue

On Drupal 8 sites running versions prior to 8.4.0 the cache_render table and overall database may rapidly increase in size, filling your disk.

Cause

Drupal 8 introduced a robust and thorough caching API. Render caching is enabled by default for many elements such as pages, entities, blocks, and views. Items in this cache do not currently expire. Prior to 8.4.0, a core bug (https://www.drupal.org/node/2526150) may have caused the cache_render table to rapidly increase in size.

Resolution

Upgrade to the latest version of Drupal core.  If this is not possible, follow one of the other mitigation options below.

Other Mitigation options

Important

Drupal core versions prior to 8.4.0 are currently unsupported. Versions of Drupal core prior to 8.4.5 contain a security vulnerability, announced in SA-CORE-2018-001. Acquia strongly recommends that Drupal core be updated to this version to minimize the risk of security vulnerabilities on your site.

If you cannot upgrade to the latest version of Drupal core you may have to manage the cache_render table size manually. This may also be the case if you installed Drupal prior to 8.4 and still have a large cache_render  table. 

  • Occasionally truncate the cache_render table
  • Selectively delete items from the cache_render table based on created date

Truncate the cache_render table

From a MySQL prompt, type: 

truncate table cache_render;

Selectively delete items from the cache_render table based on created date

From a MySQL prompt, type SELECT COUNT(expire) as 'EXPIRE' from cache_render WHERE created < 'TIMESTAMP'; where timestamp is the date in Unix Epoch time. Here are two options for getting "yesterday" in Epoch time (choose one):

date -v -1d +'%s'
expr `date +'%s'` - 86400

It's always good to get an idea of the rows involved:

SELECT COUNT(expire) as 'EXPIRE' FROM cache_render WHERE created < '1491593775';
+---------------+
| count(expire) |
+---------------+
|         27022 |
+---------------+

From there, you can modify the timestamp or delete the rows. Here's the command to delete all rows from cache_render earlier than a specific date:

DELETE FROM cache_render WHERE created < 'TIMESTAMP';

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation