A page to clear your cache
Sometimes you want to manually force the cache to be cleared. Perhaps you have a php page which is being cached, and not updating properly. Perhaps your menus have changed.
You can install devel.module, which provides you with a menu item that will clear your caches. However, you may not want devel.module installed just for this one piece of functionality.
Create a new page, with the input filter set to a filter that can run PHP. Then use the following snippet, which was shamelessly yanked from devel.module:
<?php
// the following code is shamelessly yanked from devel.module.
// please see that module for possible changes / bug fixes.
// this is function `devel_cache_clear()`
drupal_clear_css_cache();
$core = array('cache', 'cache_filter', 'cache_menu', 'cache_page');
$alltables = array_merge($core, module_invoke_all('devel_caches'));
foreach ($alltables as $table) {
cache_clear_all('*', $table);
}
drupal_set_message('Cache cleared.');
drupal_goto('/');
?>I suggest setting a URL path for this page (perhaps 'cache_clear'?) so that you can clear the cache easily. Note that the drupal_goto at the end of the page will redirect you to either the destination or to the main page of your site; you can change this if you wish.
Because of the drupal_goto, you can never actually visit this page; you can edit it through the admin/content/node page.
2007 Sep 06: update to the cache_clear_all call to reflect a change from devel.module.

Code doesn´t clear the entire cache
Concerning the description at http://api.drupal.org/api/function/cache_clear_all/5 the correct and tested code must be:
cache_clear_all('*', $table, true);LeisureLarry
Additional cache tables
For Drupal 5.7 you can also add the following cache tables:
'cache_content''cache_views'
$core = array('cache', 'cache_filter', 'cache_menu', 'cache_page');becomes
$core = array('cache', 'cache_content', 'cache_filter', 'cache_menu', 'cache_page', 'cache_views');admin only
I think you may also want to add a line like:
if (!user_access('administer site configuration')) drupal_not_found();at the top so that only site admins can run this.
Peter Lindstrom
LiquidCMS - Content Management Solution Experts
clears ALL
Keep in mind that the code above clears ALL cached variables. Quite often you may want to cache variables in your site and Drupal allows you to set expiry times for these. Using cache_clear_all() without parameters will only clear those cache variables which have expired - which sometimes may be what you wanted.
Peter Lindstrom
LiquidCMS - Content Management Solution Experts