Drupal 7 performance gains with Views cache

The Views module is the most powerful tool for a Drupal developer, and so much loved that from Drupal 8 the Views module has made it's way into Drupal core. As for Drupal 7, Views is still a contributed module and not all that famous for it's performance. This blog post will look at a few ways to improve the performance of your Views in Drupal 7 by using caching.

Block cache

Drupal 7 Views Block Cache

Drupal core has a great caching system for pages and blocks. If you generate a block within Views you can make use of this block cache from the "block caching" option under the advanced drop down of the View UI. The great thing is that this then uncovers the Drupal core block caching types such as caching per user, per page, per role, etc. This should always be enabled when creating blocks with Views.

Views cache

Drupal 7 Views time based cache

Also under the advanced drop down within the Views UI you will find a "caching" option. In here you will be able to select time based caching. This is great for pages generated by views which are unable to use block cache. The length of time to store the views query results and rendered output can be selected. Choosing 5 minutes for both these options across all Views will offer a great performance boost. If the View is something like an admin interface that needs to be up to date then it's best not to enable caching, and if the View is something that doesn't change very often then a higher value can be selected.

Views Content Cache

Drupal 7 Views Content Cache

The Views Content Cache module builds upon the standard Views cache by adding content aware caching. It allows multiple content elements to be selected, then if one of these changes the cache gets cleared. Time options can also be selected with a minimum time the View should be cached for whether the content elements change or not, then the maximum time the view should be cached for if the content element doesn't change. Ideally here the minimum should be something like 5 minutes and the maximum be as high as possible.

Summary

Most Views should have some sort of caching enabled. If the View generates a block then block caching is the best option. Otherwise Views Content Cache should offer a way to keep things in the cache as long as possible and clear the cache when needed. If neither of these fit the use case then a few minutes of Views time based cache will really help.

Simple SEO PDF guide

Get our latest PDF guide, Simple SEO.

Similar posts

Mailing list

Subscribe for monthly updates, blog posts, and client case studies direct to your inbox.

Twitter