Title: Cache Api
Last modified: September 4, 2019

---

# Cache Api

 *  Resolved [dudo](https://wordpress.org/support/users/dudo/)
 * (@dudo)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/cache-api/)
 * Hi Guys!
 * I’m Dario, the plugin developer of [Yasr – Yet Another Stars Rating ](https://wordpress.org/plugins/yet-another-stars-rating/)
 * I would like to make my plugin work with W3 Total Cache, but I’m having some 
   troubles.
 * In my plugin, when an user rate a post or page, I added an hook; here, I’m trying
   to delete the cache, using this code
 *     ```
       function yasr_w3_total_cache($post_id) {
           if (function_exists('w3tc_pgcache_flush')) {
               w3tc_pgcache_flush();
           }elseif (function_exists( 'wp_cache_clear_cache' ) ) {
               wp_cache_clear_cache();
           }
       }
       ```
   
 * But doesn’t seems to work: what am I doing wrong?
    Do you have a link to the 
   API? I couldn’t find it.
    -  This topic was modified 6 years, 9 months ago by [dudo](https://wordpress.org/support/users/dudo/).
    -  This topic was modified 6 years, 9 months ago by [dudo](https://wordpress.org/support/users/dudo/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/cache-api/#post-11901982)
 * Hello [@dudo](https://wordpress.org/support/users/dudo/),
 * I am sorry about the issue you are having and I am happy to assist you with this.
   
   You should flush that specific post via `w3tc_flush_post( $post_id )` I hope 
   this helps.
 *  Thread Starter [dudo](https://wordpress.org/support/users/dudo/)
 * (@dudo)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/cache-api/#post-11903607)
 * Thanks [@vmarko](https://wordpress.org/support/users/vmarko/) !
 * Yes, that function seems to work.
    But now there is another problem 🙂
 * After the rating is saved, if page is reloaded, I see the updated rating indeed.
 * But this version of the widget is cached now, where it’s no possible anymore 
   to vote.
 * As you can imagine, I don’t want to flush the post cache everytime YASR wisget
   is loaded.
    Is it possible to do not cache a particular class or id in the DOM?
 *  Plugin Contributor [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * (@vmarko)
 * [6 years, 9 months ago](https://wordpress.org/support/topic/cache-api/#post-11912809)
 * Hello [@dudo](https://wordpress.org/support/users/dudo/),
 * As a reference, you may check how other plugins show dynamic data e.g. Woocommerce
   show their shopping cart widget.
    Widget content is loaded via AJAX there with
   some support of local browser storage and as a result, they avoid the majority
   of problems with all caching plugins.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Cache Api’ is closed to new replies.

 * ![](https://ps.w.org/w3-total-cache/assets/icon-256x256.png?rev=1041806)
 * [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/w3-total-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/w3-total-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/w3-total-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/w3-total-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/w3-total-cache/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Marko Vasiljevic](https://wordpress.org/support/users/vmarko/)
 * Last activity: [6 years, 9 months ago](https://wordpress.org/support/topic/cache-api/#post-11912809)
 * Status: resolved