Skip to content

Purge a URL from the page cache

By default, the VIP Platform caches responses from WordPress and Node.js applications by resource URL. Subsequent requests for the same resource URL may receive a previously cached response.

Content cached by the page cache can be purged on demand in the VIP Dashboard, with VIP-CLI, or in a site’s WordPress Admin tool bar.

Cached resource URLs can be purged for:

  • Posts and pages
  • REST API endpoints
  • Static assets such as images, CSS, and JS files
  • Files stored in the VIP File System

When purging a URL from the page cache, all variants of the URL’s GET parameters will also be purged. Purging a post with slug hello-world will also purge other cached variants such as /hello-world/?a=1&b=1 as well as /hello-world/?b=1&a=1. It is not possible to purge a specific variant of a URL without purging all if its other variants.

VIP Dashboard

Prerequisite

A user must have at minimum an Org admin role or an App admin role for that application.

Cached URLs of a WordPress or Node.js environment can be purged from the cache in the Purge Page Cache panel of the VIP Dashboard.

The Purge Page Cache panel is environment-specific (e.g., Production, Develop).

  1. Navigate to the VIP Dashboard for an application.
  2. Select an environment from the environment dropdown located at the upper left of the VIP Dashboard.
  3. Select “Performance” from the sidebar navigation at the left of the screen. 
  4. Select “Cache” from the submenu.
  5. Enter one or more URLs sharing the same domain in the “URLs” text field. Multiple URLs must be separated per line by return values.
  6. Select the “Purge” button to purge the URLs from the page cache.

Up to 4,000 URLs can be purged at one time.

VIP-CLI

Purge the cache for one or more URLs (up to 4,000) that share the same domain with the VIP-CLI command vip cache purge-url.

Prerequisites

If multiple URLs are passed in the command, they must be separated by a single space.

vip @<app>.<env> cache purge-url <url> <url>

VIP-CLI command examples

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

In this command example, two URLs hosted on the develop environment of the “mytestsite” application are purged in a single VIP-CLI command:

$ vip @mytestsite.develop cache purge-url https://dev.example.com/page-path/ https://dev.example.com/wp-content/uploads/2020/12/example.png
- Purged URL: https://dev.example.com/page-path/
- Purged URL: https://dev.example.com/wp-content/uploads/2020/12/example.png

URLs with parameter strings may need to be passed to the vip cache purge-url command within quotation marks. For example:

vip @mytestsite.develop cache purge-url "https://dev.example.com/page-path/?a=b"

Purging a URL with parameter strings purges all other cached variants of that URL.

--from-file

Accepted values: A relative or absolute path to a UTF-8-encoded text file

The --from-file option extracts a list of URLs from the file existing at the relative or absolute path in the passed value.

Use the --from-file option to pass a text file containing multiple URLs (separated by newlines) to a vip cache purge-url command.

In this example command, a list of URLs contained in the multiline contents of a *.txt file named url-purge-list.txt is passed to the vip cache purge-url to purge:

vip @mytestsite.develop cache purge-url --from-file=/path/to/url-purge-list.txt

WordPress Admin cache manager

Any logged in user with a role that has the manage_options capability (usually Administrator, or Super Admin) has access to the “Purge Cache For Page” button located in the WordPress Admin tool bar.

The “Purge Cache for Page” option only appears on a site’s front end view when a user is logged in.

Screenshot of “Purge Cache For Page” button as it appears in the WordPress Admin tool bar

Select the “Purge Cache for Page” link to purge the cache for the page being viewed, as well as all file assets referenced by the page (e.g., images, CSS files, JS files).

Example screenshot of the confirmation message that appears in the WordPress Admin tool bar after purging the page cache

Cache manager filter

vip_cache_manager_can_purge_cache returns a boolean whether current user can have access to the “Purge 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 “Purge 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 );

Purging the cache programmatically

Select behaviors of the VIP page cache can be controlled by using VIP’s Cache API. The cache can be programmatically cleared for a post, term, or a specific URL with Cache API functions that are added to a WordPress application’s codebase.

Last updated: January 31, 2024

Relevant to

  • Node.js
  • WordPress