Have you tried the debug system in the plugin? That will tell you what is or not happening.
Great tip. I don’t know what to make of the results though. It seems cache only clears when I vote as a logged-in user.
What happens in WPSC when I vote as anonymous user:
10:53:14 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=1&_= supercache dir: /home/myuser/public_html/test/wp-content/cache/supercache/test.mydomain.com/wp-content/plugins/wp-postratings/wp-postratings.php/
10:53:14 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=1&_= No wp-cache file exists. Must generate a new one.
10:53:14 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=1&_= In WP Cache Phase 2
10:53:14 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=1&_= Setting up WordPress actions
10:53:14 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=1&_= Supercache caching disabled. Only using wp-cache. Non empty GET request.
10:53:14 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=1&_= URI rejected. Not Caching
I reload the page afterwards – old stuff is shown.
What happens when I vote as logged-in admin (“Don’t cache pages for known users” is unchecked):
10:56:05 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=5&_= Cookie detected: wordpress_logged_in_1b64b8eaccd745a3c91c4a1dc1905612
10:56:05 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=5&_= supercache dir: /home/myuser/public_html/test/wp-content/cache/supercache/test.mydomain.com/wp-content/plugins/wp-postratings/wp-postratings.php/
10:56:05 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=5&_= Cookie detected: wordpress_logged_in_1b64b8eaccd745a3c91c4a1dc1905612
10:56:05 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=5&_= No wp-cache file exists. Must generate a new one.
10:56:05 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=5&_= Cookie detected: wordpress_logged_in_1b64b8eaccd745a3c91c4a1dc1905612
10:56:05 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=5&_= In WP Cache Phase 2
10:56:05 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=5&_= Setting up WordPress actions
10:56:05 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=5&_= Supercache caching disabled. Only using wp-cache. Non empty GET request.
10:56:05 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=5&_= URI rejected. Not Caching
10:56:05 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=9&rate=5&_= Post change: deleting post cache files for test.mydomain.com/9/another-game-review: /home/myuser/public_html/test/wp-content/cache/wp-cache-27074f6ef064dd48f2d0c47a769458f3.html
The last line – cache is actually getting cleared as I wanted.
(Using PHP mode)
I don’t know why that happens. The first log shows the postratings file wasn’t cached. It should have shown the clear cache command running too.
I think I got something from looking at the debug logs.
If admin visits the post and “Don’t cache pages for known users” is not checked, only WP-Cache file is created (no supercache).
If anonymous user visits the post, only supercache file is created (no wp-cache).
wp_cache_post_change($post_id); actually seems to clear only wp-cache (not supercache). I’m saying this because nothing happens when I vote as anonymous user – unless admin has visited the post (and created wp-cache as a result) before.
So if I visit the said post as an admin (with “Don’t cache pages for known users” not checked), a WP-Cache file is created; then I visit as an anonymous user and vote, and wp-cache is cleared as it should!
11:59:49 /wp-content/plugins/wp-postratings/wp-postratings.php?pid=20&rate=5 Post change: deleting post cache files for test.mydomain.com/20/a-really-awesome-post: /home/myuser/public_html/test/wp-content/cache/wp-cache-a812edcce01ae89bc087f591d4ab1705.html
11:59:51 /20/a-really-awesome-post supercache dir: /home/myuser/public_html/test/wp-content/cache/supercache/test.mydomain.com/20/a-really-awesome-post/
11:59:51 /20/a-really-awesome-post Served page from supercache file using PHP.
However, an old supercache file is still served even after wp_cache_post_change($post_id); was used, so anonymous user still sees old results after refreshing the page.
I’ve looked at other plugins which might clear Super Cache, and found out that I have to “tell” it that super cache is enabled with $GLOBALS["super_cache_enabled"]=1;. So this works:
if (function_exists ('wp_cache_post_change')) {
$GLOBALS["super_cache_enabled"]=1;
wp_cache_post_change($post_id);
}
Ah, good catch. I should add that as a FAQ or to the developer docs!
Hi guys, I’m using WTI Like Post plugin (basically a thumbs up/down voting plugin) and have the same issue as the OP. I’m not sure what exactly do I need to do to NOT cache the voting results.
Thanks!