Skip to content

Flush the object cache

The object cache can be flushed with the WP-CLI command wp cache flush. WP-CLI commands must be run with VIP-CLI.

Caution

Use caution when flushing the object cache on a production environment. The performance of a site’s origin database server is protected by the object cache layer. Flushing the object cache can have negative performance implications, particularly during high traffic events.

Prerequisites

VIP-CLI is installed and has been updated to the most current version.

Command examples

VIP-CLI command examples

For demonstration purposes, the <app-name> value example-app and the <env> value production are used in the VIP-CLI command examples below. Read more about how to target environments in VIP-CLI commands.

Example command to flush the object cache for a WordPress single site or for the main site (ID 1) of a multisite network:

vip @example-app.production -- wp cache flush

Example command to flush the object cache for one specific site on a multisite:

vip @example-app.production -- wp cache flush --url=http://example.com

Flushing the object cache after a domain change

On a WordPress multisite, to fully flush persistent objects from the object cache multiple wp cache flush commands might need to be run. For example, after a site launch or a domain change, the wp cache flush command may need to be run for both the previous convenience domain value (e.g. example-app.go-vip.net) and the launched custom domain value (e.g. www.example.com):

vip @example-app.production -- wp cache flush --url=example-app.go-vip.net
vip @example-app.production -- wp cache flush --url=www.example.com

Last updated: March 25, 2024

Relevant to

  • WordPress