Disable Drupal 8 caching during development

Submitted by shiv on Sat, 12/05/2015 - 17:58

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.

Steps

  1. Copy and rename the sites/example.settings.local.php to be sites/default/settings.local.php $ cp sites/example.settings.local.php sites/default/settings.local.php
  2. Open settings.php file in sites/default and uncomment these lines: if (file_exists(__DIR__ . '/settings.local.php')) { include __DIR__ . '/settings.local.php'; } This will include the local settings file as part of Drupal's settings file.
  3. Open settings.local.php and change the to be TRUE $config['system.performance']['css']['preprocess'] = FALSE; $config['system.performance']['js']['preprocess'] = FALSE;
  4. Uncomment these line is settings.local.php to Disable the render cache and Disable Dynamic Page Cache $settings['cache']['bins']['render'] = 'cache.backend.null'; $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null'; If you do not want to install test modules and themes, set following to FALSE $settings['extension_discovery_scan_tests'] = TRUE;
  5. Open development.services.yml in the sites folder and add the following block (to disable twig cache) parameters: twig.config: debug : true auto_reload: true cache: false

Sample blackbox block

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas non porta odio, id mattis erat.

Nam sed tincidunt eros. Donec a venenatis odio, vitae commodo sem. Vivamus ullamcorper pellentesque erat, in adipiscing tortor scelerisque sit amet. Nulla pulvinar urna magna. Vivamus a ipsum lorem. Etiam adipiscing pulvinar lorem.