0

On enabling caching for anonymous users, it appears that the fivestar votes are also being cached, which is super-weird.

On disabling caching for anonymous users, things work great.

We use memcache, could that be a problem? Any suggestions about how I should go about this?

From https://drupal.org/node/285855

"When "Caching mode" is enabled (admin/settings/performance), anonymous users don't see changes in rating. Every anonymous user see rating as it was when first anonymous user visited node.

When cache is disabled anonymous users see rating correctly.

Is there some way how to use Drupal caching and at same time make fivestar working for anonymous users?"

Fix -:

"Change caching time to 1-5 minutes, will make it seem that as the amount of time it took for his vote to register."

Is this the only possible fix?

  • 1
    Not actually certain why it's weird that votes would be cached. If you render cache something, and votes are a part of that, then that's what's gonna happen. One way of working around would be for fivestar to render the number of votes with JS, but I don't know if it supports that. – Letharion Nov 1 '13 at 10:53
  • Isn't it weird that on a site with a bunch of articles, your fivestar ratings are being cached, and thus after rating an article, and refreshing the page, it simply reverts back to the original rating. – Pratik Bothra Nov 1 '13 at 16:22
  • 1
    @PratikBothra Not really, that's what you're telling it to do. You're caching the entire page for anonymous users, so the database won't be hit for the updated rating values until that page cache expires. You might get some joy with the Cache actions module. I'm sure you could use that to clear relevant cached pages when rating values are updated – Clive Nov 1 '13 at 16:45
  • @Clive Hmmm, I am beginning to understand the picture. But isn't this a common requirement for most sites? How do they handle this problem. And since fivestar has so many excellent features, why have they not added this one? These reasons made me believe that I was doing something wrong, and this wasn't the typical behaviour – Pratik Bothra Nov 1 '13 at 20:55
2

Rather than rendering the Voting widget with the rest of the page, I would add a delayed (ie. on page-load) AJAX request for every widget which would do a back-end call, render the widget (without pulling in a cached version) for the appropriate node/piece of content, and inject it back into the DOM.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.