Problem/Motivation

While debugging drupal 8 it would be very nice to disable render cache system to help narrow down issues in the render api pipeline.

Proposed resolution

Provide a setting in settings.php to allow the render caching to be completely disabled.

Remaining tasks

@todo

User interface changes

n/a

API changes

n/a

Comments

wim leers’s picture

Status: Active » Closed (duplicate)
Issue tags: +Performance, +D8 cacheability, +DX (Developer Experience)

Thanks for opening this :) That's how I remembered to do this in #2226761-23: Change all default settings and config to fast/safe production values — please try and give feedback on that patch :)

roderik’s picture

Since this is issue seems to be much more google-able for novices than a documentation page on disabling caching in your setup (if that exists):

This is how to do it now in your settings.php:

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

Using the settings proposed in #2 I get 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.php", "cache.backend.memory"? in Drupal\Component\DependencyInjection\Container->get() (line 161 of core\lib\Drupal\Component\DependencyInjection\Container.php).

Corollary, using \Drupal::getContainer()->getServiceIds() I see that cache.backend.null is not on the resulting list.
With "cache.backend" prefix I only find:

    [27] => cache.backend.chainedfast
    [28] => cache.backend.database
    [29] => cache.backend.apcu
    [30] => cache.backend.php
    [31] => cache.backend.memory

So what is the good way now?

Thanks in advance
Fred

tobiberlin’s picture

When changing these settings in a settings.php of an already installed project make sure to call PROJECT_ROOT/core/rebuild.php - this avoids the mentioned exception in #3

cfreed’s picture

Hi tobiberlin,

Thanks for this advice, but calling PROJECT_ROOT/core/rebuild.php also fires the same error!

Did I missed semothing?

fatiharchitecture’s picture

rebuild.php removes error messages but can't change the cache situation it seems it is a bug in D8 core

fatiharchitecture’s picture

at the end I disable cache with this answer I configure files and call core/rebuild.php

http://stackoverflow.com/questions/26676655/disable-entire-cache-for-development

imanoop’s picture

Hi
First you need to copy the development.services.yml from sites folder to sites/default to services.yml and changes the
twig.config:
debug: true
auto_reload: true
cache: false

It will work for disable cache at the development time.

jpkrc’s picture

I have a D8 site with a page which allows all users - including anonymous - to see a list of results files held in a directory. The list changes all the time. However, an anonymous user sees only the last cached list - which is out-of-date. I have been trying to disable page caching using various methods.

This is the only method which I have found to work:
- copy /sites/example.settings.local.php to /sites/default/settings.local.php
- edit it to uncomment the two lines which disable the caches
- edit /sites/default/settings.php at the bottom to uncomment the lines which include settings.local.php
- do a rebuild: localhost/sitename/core/rebuild.php (don't forget the .php or you get lots of error messages)

This works and the page always gives an up-to-date list of files. However, I have now lost caching for all other pages.
It would be very helpful if someone more expert than me could provide working examples of turning off the internal page cache using the render array when, say, creating a form which must never be cached (as I could not get that to work). Thanks.