n Disable caching during development in Drupal 8 | CodimTh

Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh

In this tuto, I'll show you how to disable caching during development in Drupal 8.

By default caches every page. To disable caching during development you need to setup the development environment. You can follow these steps:

  • Edit your settings.php file:

The code at the bottom of your sites/default/settings.php file should look like this.

if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
  include $app_root . '/' . $site_path . '/settings.local.php';
  • Copy sites/example.settings.local.php to sites/default/settings.local.php:
cp sites/example.settings.local.php sites/default/settings.local.php
  • Disable the CSS and JavaScript aggregation features:

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

 * Disable CSS and JS aggregation.
$config['system.performance']['css']['preprocess'] = FALSE;
$config['system.performance']['js']['preprocess'] = FALSE;
  • Disable the render cache:

Uncomment this line in settings.local.php to disable the render cache.

$settings['cache']['bins']['render'] = 'cache.backend.null';
  • Disable Dynamic Page Cache:

Uncomment this line in settings.local.php to disable dynamic page cache.

$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null';
  • Disable Internal Page Cache:

Uncomment this line in settings.local.php to disable Internal Page Cache.

$settings['cache']['bins']['page'] = 'cache.backend.null';
  • Enable Twig debugging:

Uncomment this line in settings.local.php

 * Enable local development services.
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';

To enable Twig debugging Copy and Paste following code into development.services.yml like this:

# 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
    class: Drupal\Core\Cache\NullBackendFactory
  • Clear your Drupal 8 caches:

To do this I use this Drush command: drush cr if you don’t currently use Drush, I highly recommend using it, or the Drupal Console.

Now you should be able to develop in Drupal 8 without clear caches every time. for enable cache to deploy your site juste comment these lines in sites/default/settings.php like this.

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


Or you can use Drupal Console like this:

drupal site:mode dev : disable cache during developpement.

drupal site:mode prod : enable cache during production.

Riadh Rahmi

Senior Web Developer PHP/Drupal & Laravel

I am a senior web developer, I have experience in planning and developing large scale dynamic web solutions especially in Drupal & Laravel.

Web Posts


Page Facebook