Last updated January 10, 2010. Created by karschsp on December 22, 2005.
Edited by Garrett Albright, dbeall, Jody Lynn, puregin. Log in to edit this page.
You may need to clear caches after moving your site from one host to another. Also useful when you install new modules or for troubleshooting things. It is relatively harmless. Your site might slow down a bit after-wards while the cache fills back up.
Button, button, who's got the button?
Simply go to Administer > Site configuration > Performance. Near the bottom of the page, you'll see a big fat button that says “Clear cached data.” I think you can take it from there.
A php snippet
You will never lose irretrievable data with this query. Use it as needed.
<?php
db_query("DELETE FROM {cache};");
?>The Devel Module
The devel module makes it easy to clear Drupal's cache. Just install the module and enable the developer block for easy access to cache clearing.
The Admin_menu module
The admin_menu has many time saving features, including several cache clearing options for menu, page requisites, theme registry, cache tables and administration menu. It also has cron and update.php links too.
A PHP file to clear caches and rebuild the routing tables
Be careful not to leave this on the server as anyone can clear caches if they know the file name. Create a file named clear.php with the following code. Place the file in drupal base directory and run it by browsing to http://example.com/clear.php.
<?php
include_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
drupal_flush_all_caches();
?>
Comments
Selectively clearning the content cache for a node
If you update cck fields in the database, the changes may not show up until you have cleared the content cache for that node
<?php$MYNID = 5612 // the node number
db_query("DELETE FROM {cache_content} WHERE cid LIKE '%content:%d%'",$MYNID);
$node = node_load($MYNID);
?>
Nate Andersen
Web Developer
RockstarNinja.net
may need to run update.php afterwards
This method - using drupal_flush_all_caches(), broke my installation until update.php is run also.
After performing drupal_flush_all_caches, I had various 'skipping broken view' errors from Views, and 'you have no administrative items' on admin pages.
Running the update.php page reported seems to have forced Views etc to rebuild what they needed.
This comment had me wary of
This comment had me wary of drupal_flush_all_caches(). I looked into what the devel module used for it's 'empty cache' feature and it turns out to be that exact function. Since I've been using that for a while without clobbering my site I'd say it's pretty safe if you're in a similar situation.
You may also want to look at cache_clear_all:
http://api.drupal.org/api/drupal/includes--cache.inc/function/cache_clea...