• Resolved ruutkood

    (@antenn)


    Hi!

    I am having trouble flushing front page cache of a multisite main site. On the front page there are posts listed from different subsites and I am trying to find a way to flush the page cache whenever a subsite is publishing or updating a post.

    I tried using w3tc_flush_url() function inside the save_post hook, but it does not seem to work for the main site (subsite’s front page is purged automatically on post update and is working fine):

    function clear_cache_network( $post_id ) {
        if ( wp_is_post_revision( $post_id ) )
            return;
    
        // Flush main site front page cache
        if ( function_exists('w3tc_flush_url') ) {
            w3tc_flush_url( get_home_url(1, '/') );
        }
    }
    add_action( 'save_post', __NAMESPACE__ . '\\clear_cache_network', 10, 3 );

    w3tc_flush_url( get_home_url(1, '/') ) flushes the cache perfectly when called from the main site though. Am I missing something or is there another way to achieve what I described?

    Thanks for your attention!

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Multisite page cache purging’ is closed to new replies.