Rebuilding Drupal’s cache

While theming a Drupal site, it happens often that in order to make your theming changes take place, you have to run the well known drush cr command.

If you are not sure about the inner workings of Drupal’s caching system, Compony is here to help you out.

Prequisites #

To make sure you can work smoothly, you should enable development mode for your Drupal site. You can do this by running this command on your local machine:

Terminal Created with Sketch.
Command line
drupal site:mode dev

This command is truly a livesaver for a Frontender, as it disables all sorts of caching layers of Drupal that we generally don't care about while developing.

How to configure #

Please follow the instructions in the local.config.js chapter.

Triggers #

Gulp will rebuild the cache if you

  • Add, rename, move or remove a .html.twig file
  • Add, change, move or remove a libraries.yml file
  • Add, move or remove a [component-name].theme file
  • Change the [themename].libraries.yml

This logic will apply to all the themes that you configured Gulp to listen to.

When to rebuild it manually #

When writing a new hook inside a my-component.theme file, you still need to rebuild the cache manually, as there is no way for Gulp to know what exactly has changed in your my-component.theme file.