Is that true? I'm trying to get votes from anonymous visitors with cache enabled, but when I visit site as anonymous I can see only rating I gave as an administrator and no options to vote. All permissions is changed to allow...

CommentFileSizeAuthor
#9 2014-11-05 20_56_33-Rating.png5.2 KBShane Birley
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

netikseo’s picture

Anyone to confirm or deny this?

netikseo’s picture

Hmmm, it says Development status: Under active development, but it's hard to get an answer in a month.

I'm just confused, why anyone would create a voting module that does not allow to vote anonymous visitors....

Martin.’s picture

Confirming. Rates do not update with pagecache enabled.

hommesreponse’s picture

I can confirm this is happening as well. Just went live with a site and when I turned caching on I wasn't able to vote.

James Haswell’s picture

I'm having the same issue here. It really sucks, although it seems to work sporadically.

www.stompinggrounds.com/photo-phriday

Jawi’s picture

Any progress on this one. I have same issues with the voting and fivestar module. Can not cache views because then stars disappear. Not caching view displays is realy terrible for the performance of our drupal websites.

Shane Birley’s picture

I have noticed this on some of our sites. I can confirm that caching seems to kill the function of that field.

Shane Birley’s picture

Title: Fivestar rating is not working for Anonymous visitors when cache is enabled? » Fivestar Not Working for Anonymous Users with Cache Enabled

Updating title and have now tested and confirmed that caching is not compatible with the module.

Shane Birley’s picture

I have just noticed this addition to the fields. When I set the author to anonymous on the field also set the field to allow users to vote on their own content, this appears to work as a crude work around.

Update: This only worked for a few hours.

Sifro’s picture

I'm having the same problem

Huelfe’s picture

I'm having the same problem, too. I've tried to combine Fieldblock and Ajaxblocks, but they're not working together. I'll try to write a patch for this and let you guys know.

nicholasThompson’s picture

I solved the caching problem for a client site using the following:

/**
 * Implements hook_votingapi_results().
 */
function HOOK_votingapi_results($cached, $entity_type, $entity_id) {
  // Get the Entity URI
  $uri = entity_uri($entity_type, node_load($entity_id));

  // Turn it into a URL.
  $path = url($uri['path'], array('absolute' => TRUE));

  // Use a wildcard to catch paths with query strings.
  cache_clear_all($path, 'cache_page', TRUE);
}

However the issue I have just encountered is beyond page caching, I think.. When I voted as anonymous, it was recorded against my IP. After that a colleague viewed the same page but is not allowed to vote (marked as already voted on by anonymous).

eeg’s picture

Hey Nicholas, I've created a patch that fixes the problem with only one possible anonymous vote:
https://www.drupal.org/node/2498161
Never got an answer though.

I'm now facing the same problem with caching, as we want to enable the page cache for anonymous users :(

Martin.’s picture

I solved it by reloading the fivestar widget with javascript. It was very specific solution though but the same principle could be applied here. There could be an endpoint which takes in field_type and field_instance_id and then return the html result of that field instance. This should be done automatically for all widgets on the page.

I think #12 is a slippery slope, when you have lots of people rating stuff, then the page cache becomes pointless as it is constantly clearing.

PieterDC’s picture

#2297231-12: Fivestar Not Working for Anonymous Users with Cache Enabled is indeed not ideal because it clears the whole page from cache.
A more generic solution should indeed be possible, Marin.

Huelfe tried to use existing modules, as explained in #2297231-11: Fivestar Not Working for Anonymous Users with Cache Enabled, but it wasn't working out. Maybe meanwhile both modules do work together. At least https://www.drupal.org/project/fieldblock got updates since his comment.

But I've chosen to try yet another alternative where we don't have to proxy fields through block to be able to load their content via Ajax. https://www.drupal.org/project/authcache :

Field (new in 7.x-2.x)
Load core fields using Ajax or ESI. This is especially useful together with the Fivestar module.