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-alias> value mytestsite 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 @mytestsite.production -- wp cache flush

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

vip @mytestsite.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. mysite.go-vip.net) and the launched custom domain value (e.g. www.mysite.com):

vip @mytestsite.production -- wp cache flush --url=mysite.go-vip.net
vip @mytestsite.production -- wp cache flush --url=www.mysite.com

Last updated: August 03, 2023

Relevant to

  • WordPress