Tagged: Purge Cache
- AuthorPosts
- August 18, 2021 at 3:55 am #41853Shannon HicksGuest
I’m looking to do caching & CDN for a high-traffic website that needs timely updates. The problem is that the content that is updated is driven by an external resource, and embedded in the wordpress site via a plugin. I understand that wouldn’t trigger Total Cache to update it’s local cache or invalidate the CDN cache… I’m hoping that there’s an API I can call to invalidate a single page manually. I’m not having much luck finding an answer to that question, though.
August 18, 2021 at 4:01 am #41864Marko VasiljevicKeymasterHello Shannon,
Thank you for reaching out and I am happy to assist you with this.
Short answer -yes. In wp-content/plugins/w3-total-cache/w3-total-cache-api.php you can find the purge functions.
In your case:function w3tc_flush_post( $post_id, $extras = null ) { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); $o->flush_post( $post_id, $extras );
or you can call flush for the URL:
function w3tc_flush_url( $url, $extras = null ) { $o = \W3TC\Dispatcher::component( 'CacheFlush' ); $o->flush_url( $url, $extras );
As you can see you can call w3tc_flush_post( $post_id ) or w3tc_flush_url($url)
I hope this helps!
Thanks! - AuthorPosts
- The topic ‘Does Total Cache have an API?’ is closed to new replies.