• Resolved generosus

    (@generosus)


    Good Day,

    We read your plugin’s documentation and could not find a simple procedure for clearing cache for a specific page (URL). Instead, found the following function (with no instructions):

    if (function_exists('sg_cachepress_purge_cache')) {
        sg_cachepress_purge_cache('https://yoursite.com/pluginpage');
    }

    Since we’re not coders or developers, how do we use the above function?

    Also, it makes more sense to incorporate the intent of the above function into your plugin as a Custom Purge feature (same or similar to Cloudflare’s) to make things a lot easier for all of us.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Pavel Dosev

    (@pdosev)

    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.

    Thread Starter generosus

    (@generosus)

    Hi @pdosev,

    Thank you so much for your detailed response.

    Based on your response, the following questions remain:

    1. When we modify a page, does SGO’s Automatic Purge feature clear the cache for the modified page or our entire site? Your documentation is not quite clear on this.

    2. Concerning the file and PHP code you provided: Once we create the file with the PHP code you provided, how do we execute it? (one time only or on a repeated basis).

    3. The solution you provided seems way more complicated than just updating your plugin to introduce a single interface for this purpose. Contrary to what you stated, your plugin’s interface can still remain clean and easy to use. Here’s what we had in mind. Would you kindly reconsider our request? We are very confident and 100% certain your customers would support this enhancement (and value-adding benefit).

    At our end, we always try to find good reasons to implement improvements, not excuses to reject them.

    Thank you!

    Plugin Support Pavel Dosev

    (@pdosev)

    Hello @generosus,

    Let me address your questions one at a time:

    1. When you update a post or a page, the dynamic cache of this post/page is cleared together with the homepage cache. The cache for the other posts/pages will not be cleared.

    2. You can place as many URLs in the file as you like and modify it at any time if you need to. Every execution of the script will clear the dynamic cache for the URLs listed in it. Thus you can execute it as much as you need to.

    3. This was already discussed previously in this case. We strive to keep the UI as clean as possible and only include frequently used features. With the combination of a complete cache purge, the feature to exclude whole URLs, URL patterns, post types, and the public function to cover single-page cache clearance, we provide means to clear the cache in every situation.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to Clear Cache for Specific Page (URL)’ is closed to new replies.