Caching is a critical part of running a healthy WordPress site. Thanks to caching, your site is able to use far less server resources by serving a copy of a page, rather than using PHP processes again to handle the content.
Because of this, cached content will need to be cleared when you make changes. Most of the time, actions performed within the WordPress admin will automatically clear the cache, but you might run into a situation where you need to manually clear it. In that case, you'll need to manually clear the cache.
Using WP-CLI to Flush Your Cache
While you can always clear your cache from within your WordPress admin, you may find it easier to clear the cache using WP-CLI. Here's how to do it:
- Begin by logging into your WordPress site via SSH.
- Next, navigate to your site's home directory:
- Finally, run the following WP-CLI command to flush your cache:
wp cache flush
Additional Cache Management in WP-CLI
In addition to flushing the cache, WP-CLI has many other cache-related actions that you can perform directly from the command line. For more information, see the WP-CLI documentation for the wp cache command.