7.x common.inc drupal_render_cache_get($elements)

Gets the rendered output of a renderable element from the cache.


$elements: A renderable array.

Return value

A markup string containing the rendered content of the element, or FALSE if no cached copy of the element is available.

See also



2 calls to drupal_render_cache_get()
DrupalRenderTestCase::testDrupalRenderChildrenAttached in modules/simpletest/tests/common.test
Test #attached functionality in children elements.
drupal_render in includes/common.inc
Renders HTML given a structured array tree.


includes/common.inc, line 6239
Common functions that many Drupal modules will need to reference.


function drupal_render_cache_get($elements) {
  if (!in_array($_SERVER['REQUEST_METHOD'], array(
  )) || !($cid = drupal_render_cid_create($elements))) {
    return FALSE;
  $bin = isset($elements['#cache']['bin']) ? $elements['#cache']['bin'] : 'cache';
  if (!empty($cid) && ($cache = cache_get($cid, $bin))) {

    // Add additional libraries, JavaScript, CSS and other data attached
    // to this element.
    if (isset($cache->data['#attached'])) {

    // Return the rendered output.
    return $cache->data['#markup'];
  return FALSE;


bvanmeurs’s picture

Note that this function may return an expired cache item. You need to check if the cache has expired yourself and then act accordingly.