Last updated 26 November 2017. Created on 22 October 2015.
Edited by Nick Hope, ressa, adriancid, bdlangton. Log in to edit this page.

When you are developing a module or theme you have to clear Drupal's cache (render cache, dynamic page cache, Twig cache) very often to see the changes being applied. You can disable caching for development.

So if your terminal looks like this:

$ drush cr
Cache rebuild complete.                      [ok]
$ drush cr
Cache rebuild complete.                      [ok]
$ drush cr
Cache rebuild complete.                      [ok]


then try the following:

Enable local development settings

1. Copy and rename the sites/example.settings.local.php to sites/default/settings.local.php:

$ cp sites/example.settings.local.php sites/default/settings.local.php

2. Open settings.php file in sites/default and uncomment these lines:

if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
  include $app_root . '/' . $site_path . '/settings.local.php';

This will include the local settings file as part of Drupal's settings file.

3. Open settings.local.php and uncomment (or add) this line to enable the null cache service:

$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/';

By default contains the settings to disable Drupal caching:

    class: Drupal\Core\Cache\NullBackendFactory

NOTE: Do not create, it exists under /sites

4. In settings.local.php change the following to be TRUE if you want to work with enabled css- and js-aggregation:

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

5. Uncomment these lines in settings.local.php 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';

If you are using Drupal version greater than or equal to 8.4 then add the following lines to your settings.local.php

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

If you do not want to install test modules and themes, set the following to FALSE:

$settings['extension_discovery_scan_tests'] = FALSE;

6. Open in the sites folder and add the following block to disable the twig cache:

    debug: true
    auto_reload: true
    cache: false

NOTE: If the parameters block is already present in the yml file, append the twig.config block to it.

7. Afterwards you have to rebuild the Drupal cache otherwise your website will encounter an unexpected error on page reload. This can be done by with drush:

drush cr

or by visiting the following URL from your Drupal 8 website:


Now you should be able to develop in Drupal 8 without manual cache rebuilds on a regular basis.

Your final should look as follows (mind the indentation):

# Local development services.
# To activate this feature, follow the instructions at the top of the
# 'example.settings.local.php' file, which sits next to this file.
  http.response.debug_cacheability_headers: true
    debug: true
    auto_reload: true
    cache: false
    class: Drupal\Core\Cache\NullBackendFactory

Use Drupal Console development mode

You can use Drupal Console to switch site into development mode:

Use site:mode command like this:

drupal site:mode dev

The command will override site's services.yml file and console output will show you which parameters have been changed:

$ drupal site:mode dev
 Configuration name: system.performance
 ------------------------- ---------------- ----------------
  Configuration key         Original Value   Override Value
 ------------------------- ---------------- ----------------                    false
  css.preprocess            true             false
  css.gzip                  true             false
  js.preprocess             true             false
  js.gzip                   true             false
  response.gzip                              false
 ------------------------- ---------------- ----------------

 Configuration name: views.settings
 -------------------------------- ---------------- ----------------
  Configuration key                Original Value   Override Value
 -------------------------------- ---------------- ----------------        false            true   false            true
 -------------------------------- ---------------- ----------------

 Configuration name: system.logging
 ------------------- ---------------- ----------------
  Configuration key   Original Value   Override Value
 ------------------- ---------------- ----------------
  error_level         hide             all
 ------------------- ---------------- ----------------

 Services files C:\xampp5628\htdocs\d825/sites/default/services.yml was

 New services settings
 ------------- ------------- -------
  Service       Parameter     Value
 ------------- ------------- -------
  twig.config   auto_reload   true
  twig.config   cache         true
  twig.config   debug         true
 ------------- ------------- -------


 Rebuilding cache(s), wait a moment please.

 [OK] Done clearing cache(s).



  • No activation of local.settings.php in settings.php
  • Use drupal site:mode prod to revert

Don't add comments to this page. Edit it instead

Find cache bins

To find all available (but not necessarily enabled) cache bins:

find . -type f -name *.services.yml | \
xargs sed -E -n  's/.*cache\.(.*):.*/\1/p' | \
grep -v "backend\|html.twig" | \
sort -u | \
awk -vORS=\',\' '{ print $1 }' | \
sed "s/,'$//" | sed "s/^/'/"

Note that in OSX you might need to install and run 'gawk' instead of 'awk' in order for the above command to work. You can use brew to install gawk:

brew install gawk

Then you could copy/paste it in your settings.php file and disable caching like this:

$cache_bins = array('bootstrap','config','data','default','discovery','dynamic_page_cache','entity','menu','migrate','render','rest','static','toolbar');
foreach ($cache_bins as $bin) {
  $settings['cache']['bins'][$bin] = 'cache.backend.null';

Disable cached response headers

If HTTP headers include cached Response Headers: Expires and Request Headers: Cache-Control then it is probably good to disable them during development:

On MAMP 4+ uncheck Apache settings cache_module. You might have to disable disk_cache_module and mem_cache_module as well if you are having problems restarting your apache. Close and re-open MAMP 4+.

Disable caching in your browser

Although Drupal is not caching, your browser does. That can be confusing when you have disabled all caching in the settings files and your CSS changes are not visible after a webpage reload. For example, in Google Chrome you can disable caching while the dev tools are opened:

Disable caching in Google Chrome

Disable caching in Google Chrome
CTRL + F5 (forced reload) will have the same effect in Chrome, whereas F5 seems to be enough in Firefox 57.

Alternative: develop with caching enabled

Disabling caching has some drawbacks. The whole site responds slower, and rebuilding all caches takes a while too. Doing this a lot, and all those seconds waiting for a response add up. For an approach to developing with the cache enabled, see

Sendfile Settings

Sometimes local installed environments will have Sendfile enable in their server configuration. Sendfile is used by the server to cache static files, and can greatly improve performance on production environments. However, during develop this can cause css and javascript files to be served from the cache, rather than a fresh copy. You can set Sendfile to off, depending on the environments web server (Apache or Nginx).

Apache requires an update in the httpd.conf (or sometimes apache.conf)
EnableSendfile off
Nginx requires an update in the nginx.conf
sendfile off

Looking for support? Visit the forums, or join #drupal-support in IRC.