• Resolved Anonymous User 17353382

    (@anonymized-17353382)


    I am using manageWP to keep several websites up to date. I use W3TC on all websites, so the problem I’m facing is that once I update websites, I also need to log in to every website and flush cache, in order to ensure that the updates did not break anything on the websites. This kind of defies the purpose of having a central point of management (managewp).

    Now, my need is to flush all w3tc cache remotely. I can imagine different options for that:
    1) use the w3tc api?
    2) use a php file in the root folder that calls a function to flush cache? And build some kind of tool that calls all files on all websites?
    3) following point 2, I could write a plugin that allows me to flush cache remotely?

    In any case, I’d really appreciate some assistance on how that is possible. If someone could point me in the right direction, that would be great. It seems an API call (specific url, maybe with WP credentials) would be the easiest?

    I can’t find any instructions online to accomplish any of the things I’m trying to do.

    Thank you in advance!

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello,

    Thank you for using W3 Total Cache, I am happy to assist you with this.
    There is a couple of things that you can do:
    You can flush cache via wp-cli or by removing wp-content/cache folder.
    You can also, for example, make some PHP script doing:

    include(pathtoyourwp . '/wp-load.php');
    w3tc_flush_all();

    And call it

    Thread Starter Anonymous User 17353382

    (@anonymized-17353382)

    Hi Marko, thank you for your response!

    My file looksl ike this now:

    <?php
    /*
     * Flushing the W3TC Plugin's Cache entirely
     * @package WordPress
     */
    ignore_user_abort( true );
    include('/home/clients/997b786ff3d859a1f28b627c00bf306e/<domain>' . '/wp-load.php');
    w3tc_flush_all();

    And it seems to run without an error output and without an error in the console (Chrome). So far so good.

    However, I still have some questions:
    1) How can I check if the flushing of the cache worked? When I go to the file system and check the folder “wp-content/cache” I see not much there (before and after flushing). Is there a log of this or can I somehow activate such a log?
    2) When using w3tc_flush_all(); is the page cache also flushed? And CloudFlare also (the extension is active and configured)?

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @sunyamare,

    1. When the cache is purged_old files are created in your wp-content/cache.
    It’s fine to have _old files. Please note that the pages need to be visited in order to create new cached pages if you don’t have Cache Preload setup. When a page is cached, the file is saved without _old. The _old is added when you update the page or click flush cache. This is actually done to prevent loading the cached page, force updating the page cache. Garbage collection in Performance>Page Cache, advanced sub-box is used to remove all the _old files from the cache directory.
    2. When using w3tc_flush_all();, everything is flushed including the page cache of course. Cloudflare cache is also flushed but please note that Purging your site’s Cloudflare cache will remove all CloudFlare cache files. It may take up to 48 hours for the Cloudflare cache to completely rebuild on CloudFlare’s global network.

    Thread Starter Anonymous User 17353382

    (@anonymized-17353382)

    Hi Marko,
    Thank you very much for your competent help and detailed answer!
    After switching the page cache to “disk-enhanced”, I was able to test the function you mentioned above, and it works great.
    Have a nice day!

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @sunyamare,

    I am glad I could help and everything is working as expected!

    Thread Starter Anonymous User 17353382

    (@anonymized-17353382)

    I ended up creating a tool that can flush multiple W3TC websites simultaneously using one password-protected control panel. It’s available on Github, if this could help anyone: https://github.com/web-butler/w3tc-remote-flush-multiple

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to Flush W3TC Cache Remotely?’ is closed to new replies.