On my new site all works fine so far, except that when I try to clear cache (e.g. class cache or table cache or just flush all caches) from the UI. I sometimes get an error about exhausted memory (64M on production, 128M on test site).

Are there any alternatives to clearing cache from the UI? Can I just delete all records from the database tables starting with "cache" and obtain the same result?


5 Answers 5


You can manually DELETE FROM the cache tables, though doing this with cache_form can result in wonky behavior with people in the middle of form submissions.

However, I suspect the problem isn't with clearing the cache, rather with all of the activity involved in rebuilding everything that gets cached.

Long term, you would be safest to

  • Disable modules you don't need
  • Bump up memory_limit for PHP

64M is likely on the low end if you have a lot of modules enabled. You should really download the Performance module, enable Summary Logging, run your site for a while, and see where you land on memory stats. Also note where these go when you clear caches and perform other admin functions.

  • Great module. It shows 30M - 50M for normal browsing of pages, and 64M when clearing/rebuilding cache. Clearing the cache for the first time always fails, then immediately second time fails often, then immediately third time succeeds - maybe it's progressing despite of errors. But at least I have an overview.
    – camcam
    Mar 21, 2012 at 22:27
  • Yeah, one of the functions that runs during bootstrap is hogging memory building data, which is then cached. Bump up memory_limit until you are good. I am nearly positive that this is a max limit, so normal page views won't allocate allocate all your memory. If you install xhprof, you may get the bottom of it, but my guess is it is something that you don't have a lot of control over.
    – mpdonadio
    Mar 21, 2012 at 22:52

Check the new CacheFlush module:

The fine granularity of control over cache tables and function makes this module the ultimate tool to clear the Drupal caches.

It ships with a predefined set of actions, but it's biggest strength lays in it's configuration, where one can build any number of custom presets to fit almost any need on both development and production environments. It is suitable for any role, starting from developers to administrators or editors. Access to each preset can be limited by permissions.

It allows mixing core and contrib cache tables and/or functions with low level custom rules to always clear just what's necessary, reducing precious development time.

  • How is this different than the Cache Actions module? Also, is this your module? Posting about your own module is OK, but we prefer that people disclose this fact.
    – mpdonadio
    Apr 20, 2013 at 13:47
  • @MPD It doesn't depend on Rules. And Cache Clear Presets seem to be a nice concept.
    – Gokul N K
    Jan 9, 2014 at 20:19

You may try to use drush with the following command:

echo "SHOW TABLES LIKE 'cache%'" | $(drush sql-connect) | tail -n +2 | xargs -L1 -I% echo "DELETE FROM %;" | $(drush sql-connect) -v

It will delete/truncate all the cache tables.

It's quicker and faster than the standard drush cc all method and works as far as your using SQL-based caches.

If you're using memcached, please check: What method is used to clear caches in the Drupal?


If you use the Admin Menu module on your site it has a shortcut to clear your site cache in the drop down menu when you hover over the home icon in the top right.

If you then hover over the cache clearing item there are sub-items that let you clear specific parts of the drupal cache, which means you can clear just what you want (not all individual cache tables have their own link but common ones do).

Often you only need to clear select parts so this works out well, but it also help if you want to clear all because you can clear some individually and then clear all and because you have already cleared some you will find you will probably have enough memory for the clear all.


Open settings.php (/sites/default/settings.php) in any plain text editor. Add this line to the end of the file and save it:

$settings['rebuild_access'] = TRUE;

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.