Getting Started

Session+Slides: https://amsterdam2014.drupal.org/session/render-caching-drupal-7-and-8
Drupal.org implementation for render caching comments: https://www.drupal.org/files/issues/performance_implement-2299547-17.patch

Motivation

Drupal's building and rendering process of entities is quite time consuming. This module attempts to alleviate needless rebuilding and re-rendering of entities on subsequent page loads by caching.

When an entity is updated a new cache key is generated; there's no waiting for a cache to time out.

Currently this module only aims at caching rendered entities, however if you have an idea for other general render caching please submit an issue.

How to use

Unfortunately, there's no way to hook into core Drupal functions such as node_view() to provide caching of rendered entities site wide - I tried, a lot.

However the module entity API provides an entity_view() method which renders any entity type your site provides. This module hooks into that process and essentially hijacks any entity rendering to check for caching before rendering.

If your code base consistently uses entity_view() instead of node_view(), taxonomy_term_view(), etc, then render cache can improve your page build time dramatically.

render_cache_views module can also hijack the views node view row plugin, bundled with the views module, to provide render caching.

render_cache_ds module can also hijack the views display suite row plugin, bundled with the ds module, to provide render caching.

Render cache can also take over the node/% router path and provide caching for those entities by enabling the render_cache_node module.

render_cache_comments module can hijacks the default comments display from node module.

render_cache_context can also cache blocks placed by context module.

Dependencies

Render cache can deliver the best results when used with the following modules:

  • Memcache or Memcache storage or another memory based caching module like Redis, instead of Drupal's slow database caching tables.
  • Entity cache, which caches entity loading, nicely complementing render cache.

Caveats

Render cache is a very useful tool for sites that render many entities on single pages. However there are a couple considerations to keep in mind:

Embedded entities

If your site renders entities within other entities, the parent entity's caching can prevent changes to the the child entity from being seen.

A practical example would be if you embed file entities within a field on your article node bundle. If your article nodes are render cached, and you later update a file entity, then the node that includes that entity will not update to display the changes as the render cache is not aware a related entity updated.

We're working on a solution to this, if you have any ideas on how best to solve this please submit an issue.

Permanent caching

As of right now render cache is not setting an expire time on the caches it generates. If you are using database caching tables your cache_render table will not ever clear out old items. Systems such as memcache will automatically drop unused items as space is needed, this will be fixed in a later version.

 

Created and maintained by the Bonnier Engineering Group. Learn more about Bonnier Corporation at bonniercorp.com.

 

Co-maintained by Fabianx and further development sponsored by Tag1 Consulting, Inc.

 

The comments part of this module is used on http://www.drupal.org/. :)

Supporting organizations: 
sponsored further development

Project information

Releases