We know Drupal 8 has many levels of caching:
- Render caching
- Dynamic page caching
- Twig template caching
When you are developing a module or a theme it is better to disable cache on the development stage rather than clearing cache for every change being made.
- Copy and rename the sites/example.settings.local.php file as sites/default/settings.local.php.
- In your settings.local.php file, locate the section that starts with "Disable the render cache".
-
Uncomment the $settings variable for that section:
$settings['cache']['bins']['render'] = 'cache.backend.null';
Dynamic page caching:
Dynamic page caching is when Drupal takes the entire rendered output of a page and stores it in the database (or another cache store; defaults to the database). Pages will only be cached for anonymous traffic and for users that don't have session data, like items in a shopping cart.
-
In your settings.local.php file, locate the section that starts with "Disable Dynamic Page Cache".
- Uncomment the $settings variable for that section:
$settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.null'; - Open settings.php file in sites/default directory and , locate the section that starts with "settings.local.php".
-
Uncomment the section:
if (file_exists($app_root . '/' . $site_path . '/settings.local.php')) {
include $app_root . '/' . $site_path . '/settings.local.php';
}
- open development.services.yml in the sites folder and add the following lines (to disable twig cache)
parameters:
twig.config:
debug: true
auto_reload: true
cache: false
-
Your final development.services.yml should look as follows:
- After the above steps, you need to rebuild the Drupal cache.
1 - drush cache-rebuild
2 - drush cr
-
Now After changes done, Drupal's caching system is effectively turned off.
Add new comment