When deploying a Drupal project with a continuous deployment pipeline, it is often necessary to rebuild the Drupal cache so that it takes into account the latest file changes.
Problem: While rebuilding the cache ensures that you have the latest server-side changes, it can cause additional slowness when loading pages for the first time while Drupal rebuilds the HTML cache of the various pages, views, etc.
The Drupal Warmer projet
The Warmer module solves this problem. Depending on a schedule via CRON task or manually, it allows to warm up the Drupal cache of a list of URLs defined manually or automatically by retrieving URLs from a sitemap.
Once these URLs are defined, the module loads each associated page, thus allowing them to be re-cache and a fast loading time for their next visits.
Integrating the Drupal Warmer module into a GitHub Actions pipeline
In a previous post I explained how I deploy my Drupal projects with GitHub Actions.
Here is an additional step to add to warm up the Drupal cache via Drush and using the Warmer module:
- name: Warm cache
run: ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_HOST }} "cd /var/www/html && vendor/bin/drush warmer:enqueue entity,sitemap && vendor/bin/drush queue-run warmer"