Skip to content

Backgrounds

How-to Guides

Technical References

Flush the page cache

There are several ways to flush the page cache.

VIP-CLI

This method requires VIP-CLI set up. Here’s an example:

$ vip @wpvip.production -y -- wp vip cache purge-url https://example.com/page-path/

Success: URL purged from the VIP page cache.

The URL can be any link on your site, not just a page URL. For example, you can purge a post link, a REST API endpoint, or a URL of a static asset like an image, CSS, or JS file.

Admin bar

Any logged in user with a role that has the manage_options capability (usually Administrator, or Super Admin) will have access to the “Flush Cache For Page” option in the Admin bar:

The “Flush Cache for Page” option is only available in the admin bar on front end pages.

Selecting “Flush Cache for Page” will clear cache for the page itself and all style and scripts assets loaded with the page:

Cache manager filter

vip_cache_manager_can_purge_cache returns a boolean whether current user can have access to the “Flush Cache for Page” option based on a capability check. Defaults to current_user_can( 'manage_options' ).

The following code example will enable access to the “Flush Cache for Page” option for user roles with the edit_others_posts capability (usually Editor and greater):

// Allow editors and up to be able to purge a page from cache
add_filter( 'vip_cache_manager_can_purge_cache', function( $can_purge, $user ) { 
    return current_user_can( 'edit_others_posts' );
}, 10, 2 );

Cache API

Other page cache clearing methods using the cache API can be added to an application’s codebase.

Last updated: September 24, 2021