7

I'm developing a new theme for Drupal 8. I need to disable all caching mechanisms in Drupal. I found the configuration for twig caching and CSS/JavaScript but not for other things of Drupal (like .theme files, etc.).

I found some hints here:

In the first linkt you find some entries beginning with cache. and in the second link how to deactivate probably the backend cache?

Although if I paste those two lines:

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';
$settings['cache']['bins']['render'] = 'cache.backend.null';

into my settings.php Drupal shows a message that there has been an error with the page.

TiMESPLiNTER
  • 5,741
  • 2
  • 28
  • 64

2 Answers2

14

to disable entire cache (twig + Drupal cache) :

first 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

then open settings.php file in sites/default and uncomment these lines:

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

now open settings.local.php and change the to be TRUE

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

and uncomment all these 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';

for twig cache open development.services.yml and add

parameters:
  twig.config:
    debug : true
    auto_reload: true
    cache: false

for more info https://www.drupal.org/node/2598914

John Huang
  • 1,298
  • 10
  • 14
drpl
  • 141
  • 1
  • 4
  • 3
    After this I've gotten this error : `The website encountered an unexpected error. Please try again later. Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "cache.backend.null".` To fix this just go to : *http://yoursite/core/rebuild.php* – Antoine Subit Feb 15 '16 at 10:45
  • Changing the `(...)['preprocess'] = FALSE;` lines to `TRUE` breaks serving my CSS files, I had to revert it. – That Brazilian Guy Jun 29 '16 at 21:41
  • 1
    If you get `non-existent service "cache.backend.null"` error you have not included `development.services.yml` which defines that service. – Duncanmoo Nov 16 '17 at 07:47
2

Use the Mix (https://www.drupal.org/project/mix) module to disable all these caches with just one click. No manual editing works. enter image description here

Dino
  • 23
  • 5