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 the menus have changed or your working on a theme and need a quick way to clear the cache.
You can install a module such as devel, drush or admin_menu, all of which will provide you with a menu item that will clear your caches. However, you may not want a module installed just for this one piece of functionality.
Drupal 5
Performance Settings Page
To empty the menu cache submit any of the site configuration admin forms (i.e. click on the "Save configuration" button). For example, on the performance settings page (admin/settings/performance) press the "Save configuration" button to clear the menu and page caches.
Clear cache URL or menu link
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
/*
* 2008 Jun 26
*
* The code submitted by dharmanerd in his comment probably
* works better than the original I had, so I've modified this
* to match his code.
*
* The original code for this was shamelessly yanked from
* `devel.module`; it was the function `devel_cache_clear()`.
*
*/
// only allow site administrators to visit this page:
if (!user_access('administer site configuration')) {
drupal_not_found();
}
else {
drupal_clear_css_cache();
$tables = array(
'cache',
'cache_content',
'cache_filter',
'cache_menu',
'cache_page',
'cache_views',
);
foreach ($tables as $table) {
cache_clear_all('*', $table, TRUE);
}
drupal_set_message('Cache cleared.');
drupal_goto();
}
?>Set a URL path for this page (perhaps 'cache_clear') so that you can clear the cache easily. Clear the cache by visiting the URL or add the path to a menu link(watch your permissions).
Code Notes:
- The
drupal_gotoat 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. - If this code is in a block that was visible on all pages (i.e. including the home page) then the home page would endlessly redirect to itself, breaking your site. The answer is to remove the drupal_goto() from the code, then all caches would be cleared on every page view.
- Because of the
drupal_goto, you can never actually visit this page; you can edit it through the admin/content/node page. - You may have to remove the path parameter to the function call drupal_goto, because it gets added to the homepage URL.
- If you missed some part of the code, which makes the site inaccessible you can remove the code through phpmyadmin, by browsing the block table and editing the appropriate block you created.
Drupal 5 and Drupal 6 with Devel
- Install DEVEL module: http://drupal.org/project/devel
- Enable DEVEL permissions at admin/user/access
- Make sure DEVEL block is activated & visible at admin/build/block. Make sure you're editing & using appropriate theme block.
- Click on 'Empty cache' link located inside the DEVEL block. Or use the following direct link: http://www.example.com/devel/cache/clear
by, Onopoc
Drupal 5 and Drupal 6 with Drush
http://drupal.org/project/drush
Once drush is configured, switch to the root of your Drupal directory (e.g. cd /path/to/drupal) and execute this command: drush cache clear. Works with all Drupal version, AFAIK.
by, greg.harvey
Drupal 6
Performance Settings Page
Clearing the cache can done from the performance settings page (admin/settings/performance) use the "Clear cached data" button (to clear all caches).
Drupal 6 clear cache URL or menu link
Tired of opening (admin/settings/performance) all the time, scrolling down and pressing the Clear cached data button?
Make a menu link for an easy one click cache clear without installing admin_menu or devel modules.
Create a page using the PHP Input format with the following content (taken from the devel module):
<?php
drupal_flush_all_caches();
drupal_set_message('cache flushed.');
?>Create a menu item in the Navigation menu with the path admin/clearcache (/admin/* is restricted on my site).
Now your one click away from clearing the cache.
Don't want a menu link? Visit the URL of the page to clear the cache.
by, tian

Drupal 6 clear cache URL or menu link - problem
Hi, I tried that same, it works, but it looks that script is running every time I do many different thing, like create new content!, or when I change FCK editor setup and other changes...
I created a page using the PHP Input format with the content written higher in this page + redirect back to page from where it was called.
<?phpdrupal_flush_all_caches();
drupal_set_message('My message');
drupal_goto($_COOKIE['referer2']);
?>
Shouldn't be there some "if", like page is in "view state" - I'm non-programmer, sorry...
Somehow Drupal visit that page,and run the script, without need to click right link.
So i tried this (no referrer set up), I know it is definitely ugly solution, BUT IT WORKS FOR ME:
<?phpif($_COOKIE['referer2']) {
drupal_flush_all_caches();
drupal_set_message('My message');
drupal_goto($_COOKIE['referer2']);
}
?>
How to make this like real DRUPAL solution? Thanx for our tips!