Last updated October 19, 2013. Created by pwolanin on May 12, 2010.
Edited by caktux, sanduhrs. Log in to edit this page.

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/cache-install.inc';
}
// 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 http://drupal.org/node/730046 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/cache-install.inc';
}
// 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 Drupal.org forums, or join #drupal-support in IRC.

Comments

All you need is a bunch of $conf overrides

first, tell Drupal to load your cache inc file. For example:

<?php
$conf
['cache_backends'][] = 'includes/cache-install.inc';
?>

no need to add DRUPAL_ROOT, that's added automatically

then you can tell Drupal either to use this cache by default:

<?php
$conf
['cache_default_class'] = 'DrupalFakeCache';
?>

or you can tell it to use for the page bin alone

<?php
$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/cache.inc

finally set up ommiting other bootstrap phases:

<?php
$conf
['page_cache_without_database'] = TRUE;
?>

you probably do not want hook_boot() to fire:

<?php
$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

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.

Hi:

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/cache-install.inc';
}
// 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 drupal.org, private blogs, etc that I can find. Is there the possibility that a hosting option might over-ride this or something?

Thanks.

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:

<?php
/**
* Auto-rebuild the theme registry during theme development.
*/
if (theme_get_setting('rebuild_registry') && !defined('MAINTENANCE_MODE')) {
 
// Rebuild .info data.
 
system_rebuild_theme_data();
 
// Rebuild theme registry.
 
drupal_theme_rebuild();
}
?>

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

<?php
  $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 <a href="!link">rebuild the theme registry</a>. WARNING: this is a huge performance penalty and must be turned off on production websites.', array('!link' => 'http://drupal.org/node/173880#theme-registry')),
  );
?>