How do I empty the Drupal caches:
You can also use the Drush module, which allows you to use the command line to execute popular Drupal commands, like "drush cron" or "drush cache clear".
I have the easiest solution for that. Install admin_menu module (actually not only for this purpose, once you have installed this module, you wont regret it for sure, link: http://drupal.org/project/admin_menu). Ok, then on a newly appeared top dropdown menu hover your favicon and dropdown menu will appear, and you will see: Flush all caches menu. One click - one flush. Moreover you can flush all caches together or select what to flush: Pages, menu, themes etc. Try and you will never go back )
It would be awesome if you could just GET the behavior by hitting:
http://drupal.local./admin/settings/performance?op=Clear%20cached%20data
but you can't.
However I do want to note the URL for short-cutting through the admin menu (use the latter part):
http://drupal.local. /admin/settings/performance
On-demand clearing can be done in Administer > Site Configuration > Performance.
You should setup the cron job to run every hour (or whatever interval to your liking).
When cron is run on Drupal, all caches are cleared and rebuilt without the need for a human to manually do it.
If this question pertains to theming, you should disable the caching mechanisms (css/js aggregation) and you won't have to clear the cache data when you make changes.
When you are logged as an admin (obviously, not every user of the site has to power to clear the cache), there should be a page in "Administer > Site Configuration > Performance".
And, at the bottom of the page, there should be a button (something like "Clear cached data") to clear the cache
As far as I remember, there's no need for Devel to do that, and you really don't need to go to the database, nor run some home-made PHP code.
As a reference, you can take a look at How to Clear Drupal Server-side cache
The above code is for Drupal 6.
For Drupal 7 the flush-cache module would be as follows:
<?php
/**
* Implementation of hook_menu()
*/
function flush_cache_menu() {
$items = array();
$items['flush-cache'] = array(
'type' => MENU_NORMAL_ITEM,
'title' => t('Flush the cache'),
'description' => 'Flush all website caches to make sure it updates to relect '.
'your recent changes.',
'page callback' => 'flush_cache_custom_callback',
'access callback' => user_access('flush cache'),
);
return $items;
}
/**
* Implementation of hook_permission()
*/
function flush_cache_permission() {
return array(
'administer my module' => array(
'title' => t('flush cache module'),
'description' => t('Content admin flush cache.'),
),
);
}
/**
* Function that flushes the cache
*/
function flush_cache_custom_callback() {
drupal_flush_all_caches();
return 'Caches were flushed.';
}
Note: that you then flush it by going to:
sitename.com/flush-cache
Make sure you give them permission on the permission page. Clear cache once the "normal" way if the permission doesn't appear after turning the module on.
This is preferable when you don't want your client to get access to the admin menu but you still want them to be able to flush the cache.