Cache Utility module provides an ability to view status and flush various caches in three ways:

  • Web browser user interface
  • Curl commands
  • Drush commands

The following caches are supported:

  • PHP OPCache
  • PHP APCu extension cache
  • Database cache_* tables
  • Database cachetags table
  • Clear Drupal cache via Curl

Other features

  • The module may also be configured to flush any of the above caches along with Drupal’s cache flush.
  • An optional sub-module adds links for flushing above caches under the "Drupal icon > Flush all Caches" via the contributed Admin Toolbar Extras module.

Benefits

  1. The Curl commands provide convenience of flushing various caches externally from the webserver. A single long secret code may be set to manage cache flushing on multiple sites.
  2. PHP OPCache, and APCu caches can be flushed without server restarts or adding obfuscated php files to the webserver.
  3. Enables flushing of PHP OPCache via drush which is normally not possible as drush executes using PHP-CLI and not the PHP used by webserver.
  4. Provides an ability to truncate cachetags database table which is not managed by Drupal core and in certain cases can have unlimited growth which drastically increases database size that may start to affect performance. See Drupal core issue # 3097393
  5. Provides an ability to truncate cache_* database tables.

Known issue

Truncating cache_* table for sqlite database does not work, due to unresolved Drupal core issue # 2949229


Configuration and Usage report Screenshot

Module configuration screenshot
Module usage report


Drush and Curl Commands

Documentation for the curl and drush command for each cache type is included on the module's configuration page at Configuration > Development > Cache Utility
Or at this path /admin/config/development/cache_utility

Sample commands

###############################################################################
# PHP OPCache
###############################################################################
Clear OPCache
Drush:   drush cu:opcache-clear --host https://example.com
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/opcache/clear
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/opcache/clear

Get OPCache config
Drush:   drush cu:opcache-config --host https://example.com
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/opcache/config
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/opcache/config

Get OPCache status
Drush:   drush cu:opcache-status --host https://example.com
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/opcache/status
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/opcache/status

###############################################################################
# PHP APCu cache
###############################################################################
Clear APCu
Drush:   drush cu:apcu-clear --host https://example.com
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/apcu/clear
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/apcu/clear

Get APCu config
Drush:   drush cu:apcu-config --host https://example.com
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/apcu/config
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/apcu/config

Get APCu status
Drush:   drush cu:apcu-status --host https://example.com
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/apcu/status
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/apcu/status

###############################################################################
# Database Cachetags table
###############################################################################
# View the status of database cachetags table
Drush:   drush cu:cachetags-status --host https://example.com
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/cachetags/status
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/cachetags/status

# Truncate database cachetags table
Drush:   drush cu:cachetags-truncate --host https://example.com
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/cachetags/clear
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/cachetags/clear

###############################################################################
# Database cache_* tables
###############################################################################
# View the status of database cache_* tables
Drush:   drush cu:cachetables-status --host https://example.com
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/drupalcache/status
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/drupalcache/status

# Truncate all database cache_* tables
Drush:   drush cu:cachetables-truncate --host https://example.com
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/drupalcachetables/clear
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/drupalcachetables/clear

# Clear Drupal's cache
Drush:   drush cr
Curl (site host):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' https://example.com/admin/cache_utility/drupalcache/clear
Curl (localhost):   curl -H 'Content-Type: application/json' -H 'CU-ACCESS-KEY: LONG_SECRET_KEY' http://localhost/admin/cache_utility/drupalcache/clear
Supporting organizations: 
Conceived and developed the module

Project information

Releases