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 also enable development mode for your Drupal site. You can do this by following the steps in our blogpost about disabling every caching layer

How to configure #

Please follow the instructions in configuring your local.config.js. In particular you can enable the automatic cache rebuilding feature.

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.

Something missing? #

Do you know any other trick I missed? Let me know below, and I'll add it!