Disable Cache Before developing Drupal 8 Theme

Drupal 8 Theme Developer

I recently started developing Drupal 8 theme. But every time I was making any change, I had to clear Drupal cache. So, here is how you can disable Drupal cache when developing theme / module for Drupal 8.

Step 1

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

Step 2

Open /sites/default/settings.php file and uncomment (remove # sign from beginning) these lines:

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

Step 3

Open /sites/default/settings.local.php and change value of followings to be TRUE

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

Step 4

Uncomment (remove # sign from the beginning) these line in /sites/default/settings.local.php

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

Step 5

Change value of following to FALSE in /sites/default/settings.local.php

$settings['extension_discovery_scan_tests'] = TRUE;

Step 6

Add following codes at the bottom of /sites/default/settings.local.php

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

Step 7

Open /sites/development.services.yml. Delete previous codes and and add the following codes.

# 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

Step 7

Clear cache to delete old cache.
Home >> Administration >> Configuration >> Development >> Performance

Done!!

Comments

tamkinlinks's picture

Submitted by tamkinlinks on Fri, 10/21/2016 - 17:23

good