Drupal is a registered trademark of Dries Buytaert
drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)! drupal 11.3.6 Update released for Drupal core (11.3.6)! drupal 10.6.6 Update released for Drupal core (10.6.6)! cms 2.1.0 Update released for Drupal core (2.1.0)! bootstrap 8.x-3.40 Minor update available for theme bootstrap (8.x-3.40). menu_link_attributes 8.x-1.7 Minor update available for module menu_link_attributes (8.x-1.7). eca 3.1.1 Minor update available for module eca (3.1.1). layout_paragraphs 2.1.3 Minor update available for module layout_paragraphs (2.1.3). ai 1.3.3 Minor update available for module ai (1.3.3). ai 1.2.14 Minor update available for module ai (1.2.14). node_revision_delete 2.0.3 Minor update available for module node_revision_delete (2.0.3). moderated_content_bulk_publish 2.0.52 Minor update available for module moderated_content_bulk_publish (2.0.52). klaro 3.0.10 Minor update available for module klaro (3.0.10). klaro 3.0.9 Minor update available for module klaro (3.0.9). layout_paragraphs 2.1.2 Minor update available for module layout_paragraphs (2.1.2). geofield_map 11.1.8 Minor update available for module geofield_map (11.1.8).

purge_control

209 sites Security covered
View on drupal.org

INTRODUCTION

Provides configuration to enable and disable purging along with drush commands.

REQUIREMENTS

Purge module. See: https://www.drupal.org/project/purge.

INSTALLATION

Refer the Purge documentation to get more details on how to setup the purging.
https://git.drupalcode.org/project/purge/-/blob/8.x-3.x/README.md

MODULE FEATURES

  • Provides configuration to disable and enable purging functionality.
  • Provides configuration to automatically enable purging if it is disabled.
  • Provides Drush commands to control purging on the site.

Available Drush commands:

drush pc —help # help around the command.

drush pc enp # Enables purging.

drush pc disp # Disables purging.

drush pc ena # Enables automation.

drush pc disa # Disables Automation.

CONFIGURATION

Go to admin/config/development/performance/purge/purge-control.
Automate control of enabling and disabling of purge: When this setting is
enabled, then, during cron run, if the purging is disabled then it will be re-enabled.
Disable purging: If this setting is enabled then purging will be disabled.

USAGE EXAMPLES

Maintaining CDN cache during production releases, so that no direct traffic is
reaching the site. Below are the steps to perform the mentioned setup:

Pause the purging of the site before the release using following commands:

drush pc disa
drush pc disp

After the release, restart the purging, In case of big release everything
invalidation can be added in the queue so that the whole site is purged in a
single request.

# Enable purging
drush pc ena
drush pc enp

# Trigger everything invalidation
drush pqe # Empty the queue
drush pqa everything # Adds everything invalidation object in the queue
drush pqw # Triggers purge process.

For a long running drush command which causes lots of invalidation(like migration),
Use the purge control service inside pre and post commit hooks, So that before
execution the purging is stopped and after execution purging is restarted.
Code example:
Inside pre-command hook of drush add below code:

/**
   * Disable purging at start of process.
   *
   * @hook pre-command <command-name>
   */
  public function preCommand(CommandData $commandData) {
    // Make sure to inject service via dependency injection here instead.
    \Drupal::service('purge_control.purge_control')->autoDisablePurge();
  }

  /**
   * Enabled purging at the end of process.
   *
   * @hook post-command <command-name>
   */
  public function postCommand($result, CommandData $commandData) {
    \Drupal::service('purge_control.purge_control')->autoEnablePurge();
  }

In above code snippet example we are using autoDisablePurge and autoEnablePurge
methods for triggering our process which ensures that if automation flag is set
then only this process will take place.
Learn more about drush hooks at https://github.com/consolidation/annotated-command#hooks

Other Recommended module

Purge Everything Queuer: Provides a purge queuer to queue everything invalidation, Also provides an implementation to restart the stopped purge process due to Queue getting full.

Activity

Total releases
1
First release
Feb 2025
Latest release
1 year ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
2.1.0 Stable Feb 6, 2025