6

I've set up my development setup and it works great but for some reason I can't get the twig cache to disable. I tried everything, but I have to run drush cr every time I change anything in twig templates, and it's driving me insane.

settings.php:

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

settings.local.php AND setting.php:

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

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

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

services.yml AND development.services.yml

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

I am running Drupal 8.4

0

2 Answers 2

14

In Drupal 8.4 you have to set the null cache backend for an additional cache bin, so now there are three:

settings.local.php:

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

This is because the cached pages for anonymous users moved to a separate cache bin, see the change record The internal page cache now has a dedicated cache bin.

1
0

Use the Mix module to disable drupal caches during development by just toggling an "Enable development mode" checkbox, which will saving us a lot of time in settings*.php and services*.yml files.

1
  • Version tags should be used for questions that apply to a version only, not to merely say what version a site is using. Please stop adding tags.
    – leymannx
    Feb 7, 2023 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.