2014-10-31 61 views
4

我正在为Drupal 8开发一个新主题。我需要在Drupal中禁用所有缓存机制。我发现了小枝缓存和CSS/JavaScript的配置,但没有用于Drupal的其他功能(如.theme文件等)。禁用整个缓存进行开发

我发现了一些线索在这里:

在第一linkt你发现某些条目与cache.,并在第二环节开始如何停用可能是后台缓存?

虽然如果我贴这两条线:

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml'; 
$settings['cache']['bins']['render'] = 'cache.backend.null'; 

到我settings.php的Drupal显示一条消息,指出已与页面错误。

回答

9

禁用整个高速缓存(树枝+ Drupal的缓存):

第一个副本,并重新命名​​是网站/默认/ settings.local.php

$ cp sites/example.settings.local.php sites/default/settings.local.php 

然后打开settings.php文件中sites/default和取消注释这些行:

# if (file_exists(__DIR__ . '/settings.local.php')) { 
# include __DIR__ . '/settings.local.php'; 
# } 

现已开放settings.local.php并更改为TRUE

$config['system.performance']['css']['preprocess'] = FALSE; 
$config['system.performance']['js']['preprocess'] = FALSE; 

并取消所有这些禁用渲染缓存和禁用动态页面缓存

# $settings['cache']['bins']['render'] = 'cache.backend.null'; 
# $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null'; 

的树枝高速缓存中打开development.services.yml并添加

parameters: 
    twig.config: 
    debug : true 
    auto_reload: true 
    cache: false 

更多信息https://www.drupal.org/node/2598914

+3

在此之后,我得到了这个错误:'该网站遇到了意想不到的错误河请稍后再试。 Symfony \ Component \ DependencyInjection \ Exception \ ServiceNotFoundException:您已请求不存在的服务“cache.backend.null”。“ 要解决此问题,请转至:* http://yoursite/core/rebuild.php* – 2016-02-15 10:45:12

+0

改变'(...)['preprocess'] = FALSE;''行到'TRUE'中断我的CSS文件,我不得不恢复它。 – 2016-06-29 21:41:35

+0

如果您收到'不存在的服务'cache.backend.null'错误,您没有包含定义该服务的'development.services.yml'。 – Duncanmoo 2017-11-16 07:47:07