Please explain caching in complex render arrays
http://omnifik.com/blog/render-arrays-and-cache-drupal-7 is an excellent resource, I use it as a guide when caching render arrays. The nice thing about render arrays is they are recursive. So for the hook_menu page callback you can have that function return mutiple items. As an example I have the page callback function looks like this

function my_page_callback() {
  // Form dumps values in the URL, act on them.
  $input_values_from_form = drupal_get_query_parameters();

  // Get form with URL values set in the form as defaults.
  $input_form = drupal_get_form('my_form', $input_value_from_form);

  // Build table render array.
  $table = array(
    '#theme' =&gt; 'table',
    '#pre_render' =&gt; array('my_table_pre_render'),
    '#header' =&gt; $header,
    '#rows' =&gt; $rows,
    '#links' =&gt; $links,
    '#url_queries' =&gt; $url_queries,
    '#filters' =&gt; $filters,
    '#entity_types' =&gt; $entity_types,
    '#missing_info' =&gt; $missing_info,
    '#attributes' =&gt; array('class' =&gt; array('table', 'table-striped')),
    '#attached' =&gt; array('css' =&gt; array(drupal_get_path('module', 'my_module') . '/css/table.css' =&gt; array('type' =&gt; 'file'))),
    '#cache' =&gt; array(
      'keys' =&gt; $input_values_from_form,
      // Cache this for 1 hour.
      'expire' =&gt; REQUEST_TIME + 3600,
    ),
  );

  // Put them together.
  $page_array = array($input_form, $table);

  return $page_array;
}


So this will render the input form first and the table second. Using this you can in theory split up your complex page into many smaller parts caching each array separately. 

In the above example theme_table does most of the work but some other parts get used inside my_table_pre_render so the '#theme' =&gt; 'table', here is a complex example but it shows how to do this.

Pick the keys for each render array wisely as in make it relevant only to that part of the page; see https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_render_cid_create/7.x