How to Clear Cache for Specific Page (URL)

Hello @generosus,

There isn’t a way to purge the cache of a single page through the plugin’s interface. You can exclude post types or URLs entirely from the cache, though.

Normally purging the cache for one page or part of the site is used when something is changed on it. We added the most widely used hooks and cases in WordPress, so making changes to a page through the admin will purge the cache for this page in almost any case.

You can use the function above to clear the whole cache or a specific page. As it is a specific function this should be done by a developer familiar with WordPress as it is intended for them and any customization they add to their site. For now, we are not planning on adding such a feature to the interface as we cover most real-life applications and cases with the available options in our interface and the public function. We also strive to keep the interface clean and easy to use and avoid adding all the plugin’s features.

With that said. If the above is not feasible for you, there is a way to purge the cache of a single page (or more). Of course, this applies only if you need to purge just this page(s). Otherwise, I would recommend purging the whole cache instead.

To do this, you can create a file with the following code inside your public_html, for example, and execute it:

file name: clear_cache.php
location: inside /public_html
URL to access it: https://domain.com/clear_cache.php
<?php
// Use full or relative path based on the location of the file and wp-config.php
require_once "./wp-config.php";

if (function_exists('sg_cachepress_purge_cache')) {
    sg_cachepress_purge_cache('https://domain.com/post_name');
    sg_cachepress_purge_cache('https://domain.com/post_name2');
}

You can place the file in a different folder and name it differently if you like. You only need to correct the relative path to the wp-config.php file or enter the full path to it.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer