In my situation I would like a certain block on my page with real time information to not be cached for anonymous users. Literature listed below:

cache_clear_all('modulename', 'cache')

I added this on my module inside the hook_block_view() function. This does not work though. Any directions on where I can use this function.

Here is the function information:

Clearing specific entries in cache tables
The Drupal cache API can be used to clear specific items. Caching back ends can be switched (to memcache, to flat files, etc.) without having to rewrite any code.

cache_clear_all('content:' . $MYNID, 'cache_content', TRUE);

The example above clears all items from cache that start with 'content:$MYNID*'. To ONLY remove one specific row, drop the $wildcard parameter (the "TRUE" statement in the function call) and change the format of the first parameter to omit the asterisk, which functions as a wildcard.

cache_clear_all('content:' . $MYNID . ':' . $MYNID, 'cache_content');

1 Answer 1


You can set the block's caching in hook_block_info, like so:

function MODULE_block_info()
    $blocks = array();

    $blocks["BLOCK_NAME"] = array(
        "info"  => "BLOCK TITLE",
        "cache" => DRUPAL_NO_CACHE,

    return $blocks;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.