跳转到主要内容
rli 提交于 14 May 2012

原文链接:Suppress caching (for development) or to use an external page cache

当您在开发过程中,您也许需要禁止所有的数据缓冲,这样您才能马上看到新的钩子和主题方法的效果。

这样做将对站点的性能造成损害,所以不要在已经上线并应用的站点上禁止缓冲。要想使站点进入无缓冲的开发模式,请编辑您Drupal7的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';

http://drupal.org/node/730046页面中, 对外部页面缓冲的支持夜特别提及了。要想应用外部页面缓冲(比如varnish),请在settings.php文件中假如一下代码:

$conf['page_cache_invoke_hooks'] = FALSE;

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';

然后访问Performance页面?q=admin/config/development/performance,并激活页面缓冲,并在"Expiration of cached pages"(页面过期时间)选项中,设置一个不为零的时间: