Drupal - How to delete cache after updating/deleting/adding new content using hooks?

It sounds like you've already got a custom module, but just in case you haven't see the Module Developer's Guide.

The hooks you're looking for are hook_node_insert() and hook_node_update(), and the function to clear the cache will either be cache_clear_all() or drupal_flush_all_caches. The former will let you clear specific cache bins (and even specific cache items), and the latter will clear absolutely everything.

For example:

function MYMODULE_node_insert($node) {
  drupal_flush_all_caches();
}

or to clear only the static page cache after a node has been updated:

function MYMODULE_node_update($node) {
  $nodeurl = url('node/'. $node->nid, array('absolute' => TRUE));
  cache_clear_all($nodeurl, 'cache_page');
}

Tags:

Caching

7

Hooks