Dominique De Cooman
Published on Dominique De Cooman (https://dominiquedecooman.com)

Home > Exclude polls from cache

Dominique De Cooman
Monday, October 27, 2008 - 22:01
caching [1]
poll [2]

If you've enabled voting for anonymous users [3]. You should disable the page cache for pages containing a poll node.

This piece of code will disable page cache for all nodes of type poll. You have to do it in hook_init(). (Place it in a module)

function thuis_hoftersmissen_extra_init(){
  if(arg(0) == 'node' && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    if ($node->type == 'advpoll_binary' || $node->type == 'advpoll_ranking' || $node->type == 'poll') {
      $GLOBALS['conf']['cache'] = FALSE;
    }
  }	
}


Source URL: https://dominiquedecooman.com/blog/exclude-polls-cache

Links
[1] https://dominiquedecooman.com/blog-topics/caching
[2] https://dominiquedecooman.com/blog-topics/poll
[3] http://dominiquedecooman.com/node/188