Community Documentation

Views content cache

Last updated December 26, 2010. Created by Steven Jones on July 27, 2010.
Edited by Kami Petersen. Log in to edit this page.

Views content cache provides a caching plugin to views that is smart about when the cache should be flushed. It allows you to create a cache whereby a view is only re-rendered if some content contained in that view is changed.

Views caching

The Views module provides a sophisticated plugable caching system. It is slightly different from most caching systems in Drupal modules. Views will cache both the results from the database (results cache) and the rendered results of a view (render cache.) Views will use the data from the cache when a cache plugin says that it is safe to do so.

Cache plugins tell views a maximum age of the data that should be accepted and then if there is data in the cache that is newer than that then it will be used. Cache plugins may specify different ages for the results and render caches.

Content cache

The cache plugin that comes with Views is a simple time based cache, the cache data will be used for a maximum time that you specify, e.g. one day. If new content is posted within that day that should appear in your view, it will not until the end of the day specified by the cache plugin.

The plugin that Views content cache provides however, keeps track of the time that different content types and comments (and more) were updated and then uses that to provide a max lifetime to views that factors in the new or updated content. So that data can still be cached by views, but the maximum age is dynamically adjusted to account for new content, so in theory most views can be safely cached, and will provide up to date content, but perform better than views that are generated each and every page load.

Keeping track of the different bits of content that could appear in a view is quite hard, and Views content cache basically provides a framework for doing so. There are in fact plugins for Views content cache that keep track of the different 'segments': 'node types', 'comments' or 'organic groups', etc. these can be provided by other modules and they can work together to refine the maximum age of views cache data.

Page status

About this page

Drupal version
Drupal 6.x
Audience
Programmers, Site administrators
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here