New nodes are sometimes not visible, even after several hours

GoofyX - May 14, 2008 - 17:09
Project:Advanced cache
Version:5.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

OK. I've installed advanced cache and most accompanying patches (including node_cache.patch) in a couple of 5.7 sites (using the patches I submitted in #215542: Support for Drupal 5.7). I noticed there are times that when I create a new node (blog entry) and publish it, even after several hours, it's possible that anonymous users do not get to see the new blog entry (I always create the nodes and promote them in the front page) and a "hard" refresh is needed (eg. Ctrl+R) to get the page. Is this a browser issue or a caching issue from Drupal? I have not managed to understand a pattern of behaviour of when this happens.

Thanks.

#1

tomchuk - August 8, 2008 - 15:13

I was running into this issue as well, and after much experimentation, have figured out the exact set of cache cids and tables to clear to make sure this doesn't happen. I've stuck the cache clearing logic into a hook_nodeapi in it's own module:

<?php
function cacheclear_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  global
$base_url, $base_path;

  if(
$op == 'update' || $op == 'insert'){

   
$cid = $base_url . $base_path . $node->path;
   
cache_clear_all($cid, 'cache_page', FALSE);

   
$pcid = 'map_' . $cid;
   
cache_clear_all($pcid, 'cache_path', FALSE);

   
$pcid = 'no_src_' . $cid;
   
cache_clear_all($pcid, 'cache_path', FALSE);

   
$cid = $base_url . $base_path . 'node/' . $node->nid;
   
cache_clear_all($cid, 'cache_page', FALSE);

   
$pcid = 'map_' . $cid;
   
cache_clear_all($pcid, 'cache_path', FALSE);

   
$pcid = 'no_src_' . $cid;
   
cache_clear_all($pcid, 'cache_path', FALSE);

   
$cid = 'content:' . $node->nid . ':' . $node->vid;
   
cache_clear_all($cid, 'cache_content', FALSE);

   
$cid = $node->nid;
   
cache_clear_all($cid, 'cache_node', TRUE);
   
  }
}
?>

Attached is the module if you're interested

AttachmentSize
cacheclear.tar_.gz 554 bytes
 
 

Drupal is a registered trademark of Dries Buytaert.