I recently started developing Drupal 8 theme. But every time I was making any change, I had to clear Drupal cache. So, here is how you can disable Drupal cache when developing theme / module for Drupal 8 and 9.
Step #1: Disable Aggregation
Navigate to:
Home Administration Configuration Development Performance
- Uncheck Aggregate CSS files.
- Uncheck Aggregate JavaScript files.
and save configuration. You should also clear all caches.
Step #2: Create local settings file
Copy and rename /sites/example.settings.local.php to be /sites/default/settings.local.php
Step #3: Enable local settings file
Open /sites/default/settings.php file and uncomment (remove # sign from beginning) these lines:
if (file_exists(__DIR__ . '/settings.local.php')) {
include __DIR__ . '/settings.local.php';
}
And add this line at the bottom. Save and close settings.php file.
$settings['cache']['bins']['page'] = 'cache.backend.null';
Step #4
Uncomment (remove # sign from the beginning) these lines in /sites/default/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';
Step #5
Find and un-comment below line in /sites/default/settings.local.php
$settings['cache']['bins']['page'] = 'cache.backend.null';
Step #6
Open /sites/development.services.yml. Delete previous codes and paste below codes.
# 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.
parameters:
http.response.debug_cacheability_headers: true
twig.config:
debug: true
auto_reload: true
cache: false
services:
cache.backend.null:
class: Drupal\Core\Cache\NullBackendFactory
Step #7: Rebuild
Rebuild Drupal cache by visitng following url.
example.com/core/rebuild.php
Done!!
- admin's blog
- Log in or register to post comments
Comments
good