On development platform caching can be a pain. Can I turn it off? Will it affect any of the modules that require it?

10 Answers 10


Install the devel module which adds a cache clear option for administrators. You'll find a devel block to add to a region for quick cache clearing, or if you install the admin menu and get a quick menu in the top left for clearing various caches in Drupal.

If you like the command line install drush and use the drush cc all command to clear your sites caches. Beware that currently drush cc doesn't clear the Varnish cache if that's applicable to your setup.


If you are using Drupal 7 you can always set your caching to using DrupalFakeCache, which is normally only used during the installation process. To set that, drop the following code snippet in your settings.php:

include_once(DRUPAL_ROOT . '/includes/cache.inc');
include_once(DRUPAL_ROOT . '/includes/cache-install.inc');
$conf['cache_default_class'] = 'DrupalFakeCache';

'Performance' page in administration > site configuration will allow you to enable / disable caching of selected site elements. Theme templates are typically cached more persistently but can be flushed within the same 'performance' page.

'Administration menu' module will provide a shortcut in a toolbar if cache flushes need to be done more regularly - during theme dev I find myself constantly flushing.


As far as I know there aren't any modules that require caching. If you don't want to turn it off you can clear it in the Site Settings > Performance section.

Even with caching disabled Drupal won't recognise new files added to themes until you clear the cache.

There's a some information on different ways to clear the cache over at Drupal.org


One important thing to note is that if you have a lot of stylesheets (either from your theme or from modules), then turning off CSS file optimizing has the potential to break your site in IE.

While not actually caching, it's on the same settings page and is often used with caching.

The "Flush all caches" link in the admin menu module is fantastic, by the way.


Using the Devel module opens up a few more options, including:

  • Rebuilding the theme cache on every page load (This is useful if you're a themer working on template files.)
  • A block to provide easy access to the function to empty the cache and the reinstall function

With the Devel module, and cache turned off under Performance, the only major cache you'll run into in routine development is the menu router, which can be rebuilt either using the Devel or the Admin Menu module.


If you're using Drupal 6, the "Cache Disable" module can be handy for that task if you do not wish [for some reason] to install heavier modules like Devel.


Amount of caches used with Drupal sometimes can get crazy.

Here are the common methods of disabling and clearing Drupal caches and associated with it.


Note that you can't disable all the caches, as some of them are required by Drupal.

Here is a method of disabling the caches by adding the following lines into your settings file:

// Disable caches
$conf['cache'] = 0;
$conf['block_cache'] = 0;
$conf['views_skip_cache'] = TRUE;
$conf['page_compression'] = 0;
$conf['preprocess_css'] = 0;
$conf['preprocess_js'] = 0;

If you disable all your caches, your website will be very slow, so it's not recommended for any other environments exempt your development machine.



Clear XCache caches if used:

drush eval "function_exists('xcache_clear_cache') && xcache_clear_cache();"

Or clear the cache in XCache in admin panel (/xcache-admin) if above won't work.


drush eval "function_exists('accelerator_reset') && accelerator_reset();"


drush eval "function_exists('apc_clear_cache') && apc_clear_cache();"


Clear PHP OPCache if using with PHP >=5.5

drush eval "function_exists('opcache_reset') && opcache_reset();"

Note: Above CLI command won't clear cache for Apache, as per: Opcache - Clean cache in PHP5.4 and lower.


If you're using memcached, you should clear, restart or kill your memcached with one of the methods:

As a user (one of these):

echo flush_all > /dev/tcp/
echo flush_all | nc localhost 11211 # Flush Contents Of a Memcached Server

As a root (one of these):

/etc/init.d/rc.d/memcached restart
service memcached restart
killall memcached # It's automatically restarted on OSX.

It is also advised to install memcached module with the following line in your settings file:

$conf['cache_backends'][] = 'sites/all/modules/contrib/memcache/memcache.inc';

So Memcached caches are cleared on standard Drupal clear cache.


If you're using Varnish, it's advised to install Varnish module and set the following line in your settings file:

$conf['cache_backends'][] = 'sites/all/modules/contrib/varnish/varnish.cache.inc';

So Varnish cache would be cleared together on Drupal clear cache.

Alternatively you may use curl for clearing the pages manually:

curl -X PURGE -H "Host: domain.com"

Read more: How can I clear the Varnish cache?


Clear Drupal caches via drush:

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

You may do the same at /admin/config/development/performance, as sometimes UI caches are cleared in the better way than from CLI.

Here is the useful shell script for clearing all the caches:

set -o xtrace
echo "SHOW TABLES LIKE 'cache%'" | $(drush sql-connect) | tail -n +2 | xargs -L1 -I% echo "DELETE FROM %;" | $(drush sql-connect) -v
echo 'flush_all' | nc localhost 11211 # Flush Contents Of a Memcached Server
drush eval "function_exists('opcache_reset') && opcache_reset(); function_exists('xcache_clear_cache') && xcache_clear_cache();"
drush eval 'menu_rebuild();'
set -o xtrace -
echo done.

Old question, but I just saw it popped up as a related one to a search I was doing.

Nearly all of the cache clearing methods end up calling drupal_flush_all_caches in the end. You can play around with calling this in various circumstances in your own code.


We can use the following methods to clear the cache.

  1. Visit /admin/config/development/performance and click on the Clear cache button

  2. With Drush installed, run drush cc all

  3. With database access, run the following SQL queries

    TRUNCATE TABLE cache_block;
    TRUNCATE TABLE cache_bootstrap;
    TRUNCATE TABLE cache_field;
    TRUNCATE TABLE cache_filter;
    TRUNCATE TABLE cache_form;
    TRUNCATE TABLE cache_image;
    TRUNCATE TABLE cache_menu;
    TRUNCATE TABLE cache_page;
    TRUNCATE TABLE cache_path;
    TRUNCATE TABLE cache_token;
    TRUNCATE TABLE cache_update;
  4. From PHP code, with db_query("DELETE FROM {cache}")

  5. From PHP code, calling cache_clear_all()

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.