March 6, 2021
Written by: Jon Kamke
I discovered that changing the Twig cache settings in the services.yml file did not work, at least with a Pantheon Drupal site. Thanks to the steps found on www.drupal.org/node/2598914 I was able to figure out how to disable Twig caching for front-end development. I was developing on the Pantheon platform and the following worked for me to disable Twig caching so I didn’t have to continuously run cache rebuild.
Create a settings.local.php file in sites/default/settings.local.php
In settings.php make sure this exists
if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
include $app_root . '/' . $site_path . '/settings.local.php';
}
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml'
$settings['cache']['bins']['render'] = 'cache.backend.null';
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
Clear cache with drush cr
or on the performance page in the admin.
Making changes in a Twig template should now be reflected after a page reload without having to clear the cache first.