When you are developing a module or a theme you have to clear Drupal’s cache (render cache, dynamic page cache, Twig cache) very often to see the changes being applied. You can disable caching for development. You can disable caching for development.

Enable local development settings

Create new setting environment and enable setting

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

Open settings.php file in sites/default we need to uncomment at line

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 new if not exist:

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

By default development.services.yml contains the settings to disable Drupal caching:

    class: Drupal\Core\Cache\NullBackendFactory

In settings.local.php we add two line to disable cache.

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

To disable cache css and js we can add those line to settings.local.php

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

After that, we need to disable cache on TWIG.

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

    debug: true
    auto_reload: true
    cache: false

You are doing well to disable cache on Drupal 8 in development mode.

Last step to show error when you are in development mode open settings.local.php and add:

$config['system.logging']['error_level'] = 'verbose';

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

drush cr

Use Drupal Console development mode

You can use Drupal Console to switch site into development mode:

Use site:mode command like this:

drupal site:mode dev

The command will override site’s services.yml file and console output will show you which parameters have been changed:

$ drupal site:mode dev
 Configuration name: system.performance
 ------------------------- ---------------- ----------------
  Configuration key         Original Value   Override Value
 ------------------------- ---------------- ----------------
  cache.page.use_internal                    false
  css.preprocess            true             false
  css.gzip                  true             false
  js.preprocess             true             false
  js.gzip                   true             false
  response.gzip                              false
 ------------------------- ---------------- ----------------

 Configuration name: views.settings
 -------------------------------- ---------------- ----------------
  Configuration key                Original Value   Override Value
 -------------------------------- ---------------- ----------------
  ui.show.sql_query.enabled        false            true
  ui.show.performance_statistics   false            true
 -------------------------------- ---------------- ----------------

 Configuration name: system.logging
 ------------------- ---------------- ----------------
  Configuration key   Original Value   Override Value
 ------------------- ---------------- ----------------
  error_level         hide             all
 ------------------- ---------------- ----------------

 Services files C:\xampp5628\htdocs\d825/sites/default/services.yml was

 New services settings
 ------------- ------------- -------
  Service       Parameter     Value
 ------------- ------------- -------
  twig.config   auto_reload   true
  twig.config   cache         true
  twig.config   debug         true
 ------------- ------------- -------


 Rebuilding cache(s), wait a moment please.

[OK] Done clearing cache(s).

Source: Drupal 8