Suppress caching (for development) or to use an external page cache

Last updated on
28 May 2023

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

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/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":

Help improve this page

Page status: No known problems

You can: