Views custom cache: View's all argument enabled
Views custom cache: choose cache type
Views custom cache: choose cache type options

This module provides two new simple caches for views which takes view's arguments into account:

  • Custom cache: view's all arguments: All view's arguments, including contextual and exposed filters, will be taken into account (recommended).
  • Custom cache: view's first argument: Only first view argument, even if it is a contextual or exposed filter, will be taken into account.

It is recommended to use this module in views which take arguments. From version 7.x-1.2 this module allows to enable awareness of node updates. Performance gains will vary depending on views configuration and the amount of results.

Module features:

  • You can configure cache duration time
  • You can enable/disable cache per role (cache for both anonymous and logged in users)
  • Works well with Views AJAX pagination
  • Works well with Search API views
  • Works well in combination with Boost
  • Language aware cache
  • Node cache aware of updates

How to use it?

1) Edit a View you would like to cache. On "Advanced" column (third one) look for "Caching" option and click it. Then choose the cache type which better fits your view:

  • Custom cache: view's all arguments (recommended)
  • Custom cache: view's first argument

2) Then you will be prompted to choose cache options:

  • Cache duration time
  • Cache per role?
  • Updates awareness

How does it work?

This module extends view's standart views_plugin_cache class to generate cache keys in a way which takes into account views arguments:

Format for results cache:

  • [view_name]:[display_id]:results:[md5-of-arguments]:[language_code]
  • [view_name]:[display_id]:results:[md5-of-arguments]:[language_code]:[per-role-info]

Format for output cache:

  • [view_name]:[display_id]:output:[md5-of-arguments]:[language_code]
  • [view_name]:[display_id]:output:[md5-of-arguments]:[language_code]:[per-role-info]

Depending on user selection, the cache is generated per role like in standart cache plugin or it can be shared across all roles. Cache expiration has also been extended in order to let user choose cache expiration time.

Similar modules

  • Views argument cache. This module is very similar to Views custom cache except by the fact it doesn't allow to configure cache expiration time and doesn't allow to enable/disable cache per role. However, it allows you to choose how many arguments will have to be taken into account by cache. This module is great but I decided to do Views custom cache from scratch because it didn't work for me at all with views with exposed filters (check out this issue). And most important, this module requires you to manually flush caches because they don't automatically expire.
  • Views content cache. This module is quite different of mine's because cache expiration is content based instead of time based like Views custom cache. You can set up this module to update cache once listed content is updated or a new related node has been created.
  • Boost. This module only caches pages for anonymous users. Instead, Views custom cache caches views for both anonymous and logged in users.
  • Views Custom Cache Tags. Adds cache tags to views so cache can be invalidated. For Drupal 8 only.
Supporting organizations: 
developed the module

Project information

Releases