Skip to content

Backgrounds

How-to Guides

Technical References

Flush the page cache

The rendered HTML for a requested URL is cached in page cache for up to 30 minutes on the VIP Platform. The cached content can be purged on demand with either VIP-CLI or a button located in a site’s WordPress Admin.

VIP-CLI

Prerequisite

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

Using VIP-CLI, purge the page cache for a specific URL with the wp vip cache purge-url command.
For example:

$ vip @mytestsite.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: January 09, 2022