Drupal 8 | Enter in debug mode and disable cache

Pay Attention

Even after following the instructions on this page, the caches need to be cleared every time you change a config file or you add a new file.

Copy and rename the sites/example.settings.local.php to sites/default/settings.local.php to

Open settings.php file in sites/default and uncomment these lines to include the local settings file as part of Drupal’s settings file:

<?php
...
  
if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
  include $app_root . '/' . $site_path . '/settings.local.php';
}

Open settings.local.php and uncomment (or add) this line to enable the null cache service:

<?php
...

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';

Uncomment (or add) these lines in settings.local.php to disable the render cache and disable dynamic page cache:

<?php
. . .
  
$settings['cache']['bins']['render'] = 'cache.backend.null';

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

$settings['cache']['bins']['page'] = 'cache.backend.null';

Open development.services.yml in the sites folder and add the following block to disable the twig cache:

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

Your final development.services.yml should look as follows (mind the indentation):

# Local development services.
#
# To activate this feature, follow the instructions at the top of the
# 'example.settings.local.php' file, which sits next to this file.
parameters:
  http.response.debug_cacheability_headers: true
  twig.config:
    debug: true
    auto_reload: true
    cache: false
services:
  cache.backend.null:
    class: Drupal\Core\Cache\NullBackendFactory

Afterwards you have to rebuild the Drupal cache a last time, otherwise your website will encounter an unexpected error on page reload.

!Important :
If in multisite, must use “service.yml” that you find in single site folder ( in my example is “sites => showcase.localhost => services.yml )