• Resolved dudo

    (@dudo)


    Hi Guys!

    I’m Dario, the plugin developer of Yasr – 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.
    • This topic was modified 6 years, 9 months ago by dudo.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @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

    (@dudo)

    Thanks @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

    (@vmarko)

    Hello @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.