WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
[resolved] Super cache and user ratings (2 posts)

  1. bosniamaj
    Member
    Posted 1 year ago #

    Hello,

    I am wondering if I can make this working with WP Super Cache:
    I need to have user rating system which i built without plugins, and I really like WP Super Cache, but I have some problems.
    I can't figure out how to display right data when the content is cached.

    So, if user votes on the post, vote count is the same until the cache refreshes automatically.

    Any ideas to make this working properly? Maybe some solution like flushing the cache when the rating changes, or something like that?

    P.S. I am using mod_rewrite to serve the cache.

    Thanks.

    http://wordpress.org/extend/plugins/wp-super-cache/

  2. bosniamaj
    Member
    Posted 1 year ago #

    I managed to resolve this by using wp_cache_post_change($post_id).

    So, for all of you in need for similar solution, this is my code:
    When user votes, the vote is registered by ajax post, and the function that registers it calls this one:

    function my_clear_cache_for_post($post_id)
    {
        global $cache_path;
        if(function_exists("wp_cache_post_change"))
        {
            $GLOBALS["super_cache_enabled"]=1; /* in the documentation it says it may be necessary */
            wp_cache_post_change($post_id);
        }
        return false;
    }

    EDIT 1: I stumbled into this post, and it seems to be the same problem, and the same solution, but I couldn't google it out, sorry for posting duplicate content :(

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic