How can i show comments, as soon as they are added by anonymous user, even with the cache enabled?

Thank and sorry for my ugly english.

Comments

hannesh’s picture

Only in D 6.x. Right now all comments on the page are from anonymous users and very often people write the comment twice, because they don't see their comments right away and interpret it as a tech. failure.
Any help appreciated. mods., code, settings?

darrenlambert’s picture

You need to clear the cache, as the page is cached for anonymous users.
See this page which is for Drupal 6.
http://www.seo-expert-blog.com/blog/clearing-drupals-page-cache-after-ad...

Below is the code for Drupal 5. I found I had to change the insert call as well, so my code looks like this.

function themename_comment($a1, $op) {
  switch ($op) {
    case 'insert':
      $nid = $a1['nid'];
      break;
    case 'update':
      $nid = $a1['nid'];
      break;
    case 'unpublish':
    case 'delete':
      $nid = $a1->nid;
      break;
  }
  if ($nid) {
    // retrieve the absolute url for the node
    $url = url('node/'. $nid, NULL, NULL, TRUE);
    // delete cache entries for that url
    cache_clear_all($url, 'cache_page');
  }
}

Baraka
Camper Vans