Last updated November 20, 2015. Created on May 12, 2010.
Edited by batigolix, drupalshrek, caktux, sanduhrs. Log in to edit this page.

This instruction is for Drupal 7 read about disabling caching in Drupal 8

When developing for Drupal you might want to suppress all caching of data to make sure new hooks, theme functions, etc are recognized immediately.

This will have performance detriments, of course, so must not be used in production. To turn on this development mode, add the following to your Drupal 7 settings.php file:

if (!class_exists('DrupalFakeCache')) {
  $conf['cache_backends'][] = 'includes/';
// Default to throwing away cache data
$conf['cache_default_class'] = 'DrupalFakeCache';

// Rely on the DB cache for form caching - otherwise forms fail.
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

in support for external caches was further enhanced. To use an external page cache (e.g. Varnish) add the following to settings.php:

if (!class_exists('DrupalFakeCache')) {
  $conf['cache_backends'][] = 'includes/';
// Rely on the external cache for page caching.
$conf['cache_class_cache_page'] = 'DrupalFakeCache';

Then navigate to the Performance page at ?q=admin/config/development/performance and enable the page cache and set a non-zero time for "Expiration of cached pages":

Looking for support? Visit the forums, or join #drupal-support in IRC.


andypost’s picture

All you need is a bunch of $conf overrides

first, tell Drupal to load your cache inc file. For example:
$conf['cache_backends'][] = 'includes/';
no need to add DRUPAL_ROOT, that's added automatically

then you can tell Drupal either to use this cache by default:
$conf['cache_default_class'] = 'DrupalFakeCache';

or you can tell it to use for the page bin alone
$conf['cache_class_cache_page'] = 'DrupalDatabaseCache';

you can write your own implementation of cache class for you own cache backend taking example from DrupalDatabaseCache in includes/

finally set up ommiting other bootstrap phases:
$conf['page_cache_without_database'] = TRUE;

you probably do not want hook_boot() to fire:
$conf['page_cache_invoke_hooks'] = FALSE;

finally depending on your setup you might want to set up omit_vary_cookie but this is very advanced. Docs in drupal_serve_page_from_cache() and _drupal_bootstrap_page_cache()

EDIT: Externals cache been fixed in #804864: External page caching does only work when "page_cache_invoke_hooks" is set to FALSE. (Old "Aggressive Mode" is on)

D7 commit

D8 commit

vjcoop’s picture

This module did not work on Drupal 7. I simply want the theme to reload css on every page load to develop a custom template. So far I have installed the devel plugin and set its options, plus hacked the settings.php and set the options as indicated above and cleared the cache.

The only thing that appears to work is manually deleting the cache files at each test cycle.

Need a better option for Drupal 7 theme devel.

vjcoop’s picture


I've installed the Devel module, suppressed all caching, even gone in and manually clicked the clear cache button in the drupal admin interface, and added these lines to settings.php:

if (!class_exists('DrupalFakeCache')) {
$conf['cache_backends'][] = 'includes/';
// Default to throwing away cache data
$conf['cache_default_class'] = 'DrupalFakeCache';

// Rely on the DB cache for form caching - otherwise forms fail.
$conf['cache_class_cache_form'] = 'DrupalDatabaseCache';

NOTHING clears this theme cache. Its very hard to do custom theme development when the CSS files won't update. I don't get it, I've read every article on, private blogs, etc that I can find. Is there the possibility that a hosting option might over-ride this or something?


amanaplan’s picture

Are you sure you're not meaning to rebuild the theme registry instead?

To rebuild the theme registry and the theme .info file during development, add this to your theme's template.php file:

 * Auto-rebuild the theme registry during theme development.
if (theme_get_setting('rebuild_registry') && !defined('MAINTENANCE_MODE')) {
  // Rebuild .info data.
  // Rebuild theme registry.

And add this to your theme's theme-settings.php within your {themename}_form_system_theme_settings_alter(&$form, $form_state) function:

  $form['rebuild_registry'] = array(
    '#type'          => 'checkbox',
    '#title'         => t('Rebuild theme registry on every page.'),
    '#default_value' => theme_get_setting('rebuild_registry'),
    '#description'   => t('During theme development, it can be very useful to continuously rebuild the theme registry. WARNING: this is a huge performance penalty and must be turned off on production websites.', array('!link' => '')),

zack.wd’s picture

I have a frontend Akamai cache,so wanted to disable default page cache since i suspect mysql is loaded due to excessive cache rebuilding since we have frequent updates in our site.Any idea how to do it in Drupal 6?

jmary’s picture

Implementing this setting actually throws a fatal error :

in /var/sites/frstaging/includes/ Stack trace: #0 /var/sites/frstaging/includes/ module_implements('system_theme_in...') #1 /var/sites/frstaging/modules/system/system.module(2511): module_invoke_all('system_theme_in...') #2 /var/sites/frstaging/includes/ _system_rebuild_theme_data() #3 /var/sites/frstaging/includes/ list_themes() #4 /var/sites/frstaging/includes/ _drupal_maintenance_theme() #5 /var/sites/frstaging/includes/ drupal_maintenance_theme() #6 /var/sites/frstaging/includes/ _drupal_log_error(Array, true) #7 [internal function]: _drupal_exception_handler(Object(Error)) #8 {main} thrown in /var/sites/frstaging/includes/ on line 733

Julien MARY