7

I did Disable Drupal 8 caching during development step by step ( also finally rebuild the cache) but yet my changes in twig files not take effects without rebuild the cache.

sites/default/services.yml :

parameters:
    session.storage.options: { gc_probability: 1, gc_divisor: 100, gc_maxlifetime: 200000, cookie_lifetime: 2000000 }
    twig.config: { debug: true, auto_reload: true, cache: false }

sites/default/settings.php :

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

sites/default/settings.local.php :

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;

sites/development.services.yml :

services:
  cache.backend.null:
    class: Drupal\Core\Cache\NullBackendFactory
parameters:
  twig.config:
    debug: true
    auto_reload: true
    cache: false

Where is the Problem?

4
  • did you restart apache after making changes?
    – No Sssweat
    Jun 5, 2016 at 10:44
  • @NoSssweat everything seems Ok,after your comment I try that but no achievement .
    – Yuseferi
    Jun 5, 2016 at 11:26
  • in sites/default/settings.local.php uncomment the $settings['cache']['bins']['render'] = 'cache.backend.null'; line
    – No Sssweat
    Jun 5, 2016 at 13:05
  • 1
    @NoSssweat I found my solution with ` $settings['cache']['bins']['render'] = 'cache.backend.null'; $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';` . thanks for your attention
    – Yuseferi
    Jun 5, 2016 at 13:13

4 Answers 4

13

I resolved my problem by following lines in settings.local.php.

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

duplicate the line and enable it (by remove # before it) and change render to dynamic_page_cache I mean the following line resolved your issue

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

in Drupal >= 8.8 use

  $settings['cache']['bins']['render'] = 'cache.backend.memory';
1
  • $settings['cache']['bins']['render'] = 'cache.backend.memory'; Works for drupal 8.7.3 too
    – KTM
    Jun 8, 2020 at 7:17
3

In Drupal 8.8 adding this to sites/default/settings.local.php worked for me:

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

For some reasons when I try to add it as recommended ('cache.backend.null') I have the following error

Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "cache.backend.null". Did you mean one of these: "cache.backend.apcu", "cache.backend.memory", "cache.backend.php"?
1

For those who are struggling for configuring caching for Drupal 8, the following steps resolve the issue.

  • Copy the example.settings.local.php which is located outside of the files folder into files folder with settings.local.php
  • Uncomment $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
  • Uncomment $settings['cache']['bins']['page'] = 'cache.backend.null'; too
0

Now there is a SUPER EASY way to do this. Install the Mix module, and toggle the Enable development mode checkbox to turn off/on twig cache and other caches with just a click. No need to edit settings.php and *services.yml files back and forth.

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.