Skip to content

WP‐CLI

Joe Cartonia edited this page Sep 2, 2025 · 1 revision

WP-CLI is the command-line interface for WordPress, allowing users to manage their WordPress installations directly from the terminal. W3 Total Cache is a popular WordPress caching plugin designed to improve website performance and reduce load times.

Integration and Usage: W3 Total Cache offers a dedicated set of WP-CLI commands for managing its functionalities, including:

Clearing Caches: The most common use case is to programmatically clear various caches (page cache, database cache, object cache, browser cache, etc.) after updates, content changes, or deployments. This can be achieved using commands like wp w3-total-cache flush.

Managing Settings: While less common for routine tasks, some W3 Total Cache settings can be managed via WP-CLI, which can be useful for automated deployments or specific configurations.

Enabling/Disabling Features: Certain W3 Total Cache features can be enabled or disabled through WP-CLI commands, offering granular control.

SYNOPSIS

  • wp w3-total-cache
  • wp w3tc

SUBCOMMANDS

cdn_purge Purges URLs from CDN and Varnish if enabled. fix_environment Creates missing files, writes Apache/Nginx rules. flush Clear something from the cache. import Imports configuration file. option Get or set option. pgcache_cleanup Generally triggered from a cron job, performs manual page cache Garbage collection. pgcache_prime Generally triggered from a cron job, performs manual page cache priming. querystring Update query string for all static files.

Usage:

wp w3-total-cache cdn_purge
wp w3-total-cache fix_environment [<server>]
wp w3-total-cache flush <cache> [--post_id=<id>] [--permalink=<post-permalink>]
wp w3-total-cache import <filename>
wp w3-total-cache opcache_flush
wp w3-total-cache option <operation> <name> [<value>] [--state] [--master] [--type=<type>] [--delimiter=<delimiter>]
wp w3-total-cache pgcache_cleanup
wp w3-total-cache pgcache_prime [--start=<start>] [--limit=<limit>]
wp w3-total-cache querystring
Clone this wiki locally