How to Prevent Drush updb from Clearing Caches During Deployment

Drush

By default, the drush updb The command clears Drupal caches, which can slow down deployments and add unnecessary load. In a recent blog post, Matt Glaman shows how to override this behaviour using a custom Drush pre-command hook that automatically sets the --cache-clear flag to FALSE. This approach helps maintain performance and reduces risk in automated workflows.

The hook involves registering a method with the HookManager::PRE_COMMAND_HOOK type, targeting the UpdateDBCommands::UPDATEDB command. Within the hook, the $commandData->input()->setOption('cache-clear', FALSE); call disables the default cache clearing. While some consider this a controversial move due to the need for structured cache invalidation strategies, it’s an effective solution for teams focused on efficient, high-performance Drupal deployments—especially in CI pipelines or local development environments where speed matters.

Disclosure: This content is produced with the assistance of AI.

Disclaimer: The opinions expressed in this story do not necessarily represent that of TheDropTimes. We regularly share third-party blog posts that feature Drupal in good faith. TDT recommends Reader's discretion while consuming such content, as the veracity/authenticity of the story depends on the blogger and their motives. 

Note: The vision of this web portal is to help promote news and stories around the Drupal community and promote and celebrate the people and organizations in the community. We strive to create and distribute our content based on these content policy. If you see any omission/variation on this please reach out to us at #thedroptimes channel on Drupal Slack and we will try to address the issue as best we can.

Upcoming Events

Latest Opportunities