• Hi, I would like to create a script in function.php to empty the cache each time posts and pages are updated or published.

    Has anyone done something like this?

    The purge_all() function; do you think it would work?

    Ex:
    function flush_cache_on_update( $post_id ) {
    if ( function_exists( 'purge_all' ) ) {
    purge_all();
    }
    }
    add_action( 'publish_post', 'flush_cache_on_update' )
    add_action( 'publish_page', 'flush_cache_on_update' );

    Thanks in advance for the support

Viewing 1 replies (of 1 total)
  • Plugin Contributor Ipstenu (Mika Epstein)

    (@ipstenu)

    ?????? Advisor and Activist

    You could do that, yes. It should work, but be warned that will be a heavy toll on your site speed, depending on how many posts you have and how often you publish. I recommend instead adding the specific pages that the plugin is missing.

Viewing 1 replies (of 1 total)
  • The topic ‘Purge cache every update’ is closed to new replies.