Drupal Caching strategies I read this interesting article on Drupal caching, but I'm not sure which caching method I should be using.  

My code is implementing a menu callback, and returning a renderable array.
What is the difference between method #1 and method #2?  

Please see the question embedded as a comment in method#2

// Method #1.
function my_module_menucallback() {
  $render_array = &amp;drupal_static(__FUNCTION__);
  if (!isset($my_data)) {
    if ($cache = cache_get('my_module_data')) {
      $render_array = $cache-&gt;data;
    }
    else {
      // Do your expensive calculations here, and populate $render_array
      // with the correct stuff..
      cache_set('my_module_data', $render_array, 'cache');
    }
  }
  return $render_array;
}

// Method #2.
function my_module_menucallback() {
  // ** Do the calculations and population of $render_array that would occur here
  // get called repeatedly if this method of caching is used??? **

  $render_array ['my_content'] = array(
    '#cache' =&gt; array(
      'cid' =&gt; 'my_module_data',
      'bin' =&gt; 'cache',
      'expire' =&gt; time() + 360,
      ),
    // Other element properties go here...
    );
  return $render_array;
}


Please ignore the time specified, as this is just sample code.
So I tested and there is a significant difference between the two that I failed to understand originally.  Calculations not surrounded with ...

$render_array = &amp;drupal_static(__FUNCTION__);
  if (!isset($my_data)) {
    if ($cache = cache_get('my_module_data')) {
      $render_array = $cache-&gt;data;
    }
    else {
      // Do your expensive calculations here
      cache_set('my_module_data', $render_array, 'cache');
    }
  }


...are executed every time the menu callback function is called (every time user visits that page).

Method #2 caches only the final, rendered output.  So if your calculations/processing in the method has changed the output value and you've cached the rendered output, you will not see the updated value until the cache is cleared.