• Resolved Agency Dominion Inc.

    (@agencydominion)


    Hello Raul,

    Is there any way to purge all multisite site caches at once? Either via an admin setting, a WP CLI command, or a function within the plugin?

    Thank you for the excellent minify plugin.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Raul P.

    (@alignak)

    Hi there,
    Yes, under the Pro tab, there’s an option to define a fixed path for your cache.
    If you set up a directory there, such as /path/to/yoursite/www/wp-content/uploads/somedir when you click purge, it will purge all files for the network.

    Just make sure that when you do that, that the “page cache” is being cleared if you use a plugin, else you are deleting files that are referenced somewhere else, on the cache html, and those will no longer be available.

    By default, FVM clears the cache of several plugins and providers… but double check that.

    Thread Starter Agency Dominion Inc.

    (@agencydominion)

    Hello Raul,

    Thank you for the fast reply. This solution does work but we would prefer not to loose the benefit of having the cache files stored in unique folders per-site.

    If we have a multisite network with 200 sites, having 500+ files in the FVM admin status screen would be difficult to navigate.

    Ideally we could have the cache files stored in individual folders per-site (i.e. the default setup) so that the Status screen would show files for just the individual Site and so that you could purge the cache directory for the individual Site, but then have an option to purge the entire network as well (for example if a network-wide plugin were updated).

    A WP CLI command would be excellent, or even a function that loops through all of the sites on the network and purges the cache for each.

    Is there a function within the plugin that would take a Site ID and purge the cache for that site?

    Plugin Author Raul P.

    (@alignak)

    Hmm, I get your point.

    Currently, that would need to be coded… I’ll add it to the roadmap and look into it when I have some time. I don’t have any network install right now for testing, but will do sometime.

    As for wp-cli, I just added purge to the latest version, but it’s not network wide.

    wp fvm purge for normal installs, then I’ll add wp fvm purge --network soon.

    Edit:

    By the way, can you do a quick test for me and see if you can purge a specific site on the network via wp-cli?

    wp --url=blog.example.com fvm purge

    And if it does, then maybe something like this to purge all?

    wp site list --field=url | xargs -n1 -I % wp --url=% fvm purge

    • This reply was modified 6 years, 10 months ago by Raul P..
    Thread Starter Agency Dominion Inc.

    (@agencydominion)

    Hello Raul,

    Thanks again for your quick reply. The following CLI commend did work correctly to purge the individual site!

    wp --url=blog.example.com fvm purge

    The purge all command also worked, though I was running it on a Local by Flywheel multisite install as the root user, so it gave me the following error at first:

    Error: YIKES! It looks like you're running this as root. You probably meant to run this as the user that your WordPress install exists under.
    
    If you REALLY mean to run this as root, we won't stop you, but just bear in mind that any code on this site will then have full control of your server, making it quite DANGEROUS.
    
    If you'd like to continue as root, please run this again, adding this flag:  --allow-root
    
    If you'd like to run it as the user that this site is under, you can run the following to become the respective user:
    
        sudo -u USER -i -- wp <command>

    So after running it with the --allow-root flag, it worked and output the following:

    wp site list --field=url | xargs -n1 -I % wp --url=% fvm purge --allow-root
    Success: FVM and other caches were purged.
    Success: FVM and other caches were purged.
    Success: FVM and other caches were purged.
    Success: FVM and other caches were purged.

    So perhaps this command would work have worked fine without the --allow-root flag if I were logged into a server via a regular user with SSH access rather than root. I will try testing that out today if I can.

    Thank you for your help on this, it is coming together!

    Plugin Author Raul P.

    (@alignak)

    Yeah, you always need to add --allow-root to any wp-cli command, if you’re running it as root. It’s a wp-cli feature. You don’t need that, for other users without root privileges.

    Glad it works fine.

    Thread Starter Agency Dominion Inc.

    (@agencydominion)

    Hello Raul,

    One other thing that might help if you are working on developing a built-in multisite network purge command.

    If I run the command you provided above to purge all network sites on a multisite network on which not all of the sites have FVM installed, I get the following output:

    Error: 'fvm' is not a registered wp command. See 'wp help' for available commands.
    Success: FVM and other caches were purged.
    Success: FVM and other caches were purged.
    Error: 'fvm' is not a registered wp command. See 'wp help' for available commands.
    Success: FVM and other caches were purged.
    Error: 'fvm' is not a registered wp command. See 'wp help' for available commands.
    Error: 'fvm' is not a registered wp command. See 'wp help' for available commands.
    Success: FVM and other caches were purged.
    Success: FVM and other caches were purged.
    Success: FVM and other caches were purged.
    Error: 'fvm' is not a registered wp command. See 'wp help' for available commands.
    Success: FVM and other caches were purged.
    Error: 'fvm' is not a registered wp command. See 'wp help' for available commands.
    Error: 'fvm' is not a registered wp command. See 'wp help' for available commands.
    Success: FVM and other caches were purged.

    It hangs for a little while on the sites that throw an error, so perhaps there would be a more efficient way to test whether or not FVM is active on a site before running the purge command.

    Thanks again for your help and for the great plugin.

    Plugin Author Raul P.

    (@alignak)

    You could perhaps make a shell script for that, but wp-cli gives you the tools you need.

    https://developer.www.ads-software.com/cli/commands/plugin/is-installed/

    You could loop through the sites list, check if it’s installed or not and run your code.

    I may add a command in the future, but for now this is what is available, sorry.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Multisite purge all’ is closed to new replies.