• Resolved argdev

    (@argdev)


    Hello,

    I am creating a webhook function and I need a way to clear all the cached assets programmatically, the plugins uses the clearAllCache function in WpAssetCleanUp\OptimiseAssets\OptimizeCommon but I can’t make it work inside my function.
    Note that I need to purge everything because the webhook is run once I update code like .js or .css, thanks.

    What I have so far is:

    function clear_cache_all( $return_args, $identifier, $response_body ){
    
        $custom_action = new WpAssetCleanUp\OptimiseAssets\OptimizeCommon;
    
        $foo = $custom_action->clearAllCache(false); // the assets are never purged
     
        return $return_args;
    
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Gabe Livan

    (@gabelivan)

    @argdev although the method’s name is clearAllCache (perhaps it would be renamed at some point), it doesn’t go through literally all .css and .js files and deletes them. Whenever the “Settings” page is updated as well the CSS/JS manager (e.g. you unload a CSS file, the cache should be re-built as you might have that file inside a combine CSS file), the function clears outdated CSS/JS based on the “Clear previously cached CSS/JS files older than (x) days” option from “Settings” -> “Plugin usage preferences”.

    Active CSS/JS are never deleted, otherwise, it will break the website’s layout. Also, you might have older CSS/JS referenced by Google Cache or old cached HTML pages. That’s why some of the files are kept. As you likely know caching can be a tricky thing and the last thing a customer expects is a broken website. I’ve seen caching mechanisms that were clearing everything and when you previewed the website via Google Cache or accessed certain cached HTML pages (e.g. by the hosts caching engine that wasn’t cleared yet), then the entire layout was broken, not desirable, even for the small percentage of visitors accessing it.

    the plugins uses the clearAllCache function in WpAssetCleanUp\OptimiseAssets\OptimizeCommon but I can’t make it work inside my function.

    What exactly is not purged? Can you be more specific?

    Plugin Author Gabe Livan

    (@gabelivan)

    @argdev, as I didn’t hear from you and everything, is working fine with the clearing of the caching (no other reports being made by any other user), I’ll mark this topic as “resolved”. If you still have any issues, feel free to post them here!

    Thread Starter argdev

    (@argdev)

    Hey there,

    Sorry that I didn’t reply. I thought I did.

    Basically I need to emulate the to bar button Clear cached assets/js.

    I administer some sites and whenever I update some css or js files I have to flush W3TC and your plugin’s cache. For the former I can do it with a webhook and a function but for yours I wasn’t able yet.

    Basically I need a guy to do what the button on the admin but inside my function.

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Purge cache programmatically’ is closed to new replies.