Introducing Views Cache Bully: You're gonna cache your views, and you're gonna like it.

views cache bully admin settingsTucked away under the Views UI's "advanced" fieldset is a too-seldom-used option: Views caching. It allows you to cache the query results and/or rendered markup for any given view. This can drastically improve your site's performance.

Unfortunately, many people don't use this option. Maybe they don't know about it, maybe they've forgotten about it, or maybe they don't like. Well, the Views Cache Bully module is here to say "Too bad. You're gonna cache your views, and you're gonna like it."

To quote Dave Stoline (dstol):

Views Cache Bully some serious assumptions about caching your views. It forces caching down your throat

How does it work?

This is pretty straightforward module. It works by setting the views_plugin_cache_none plugin to use the views_plugin_cache_time plugin. Once enabled, all of your site's uncached views will be using time-based caching. The settings for bully-enforced caching can be globally administered on a settings page, which requires the "administer views cache bully" permission. This will keep naughty content admins from trying to pull a quick one.

If you'd rather not use the globally set cache expirations, that's fine. You can still choose customized time-based caching per view—you just can't get away with no caching. Well, maybe you can.

Administrators with sufficient permissions may make exemptions for specific views. This is most important for views with exposed filters (which don't always play well with caching). By default, views that use exposed filters are exempt. This is a bully with a heart of gold.

Seems like a good module idea to me. I saw that you had a couple commits in there. Nice work.

Thanks for the post about this. I'm sure it could help out many of the sites i've been working on.

Sometimes changing a default behavior in a module gets too bureaucratic... Views is already a module with huge userbase and it's coming to core in D8, so I guess changing a default behavior would sit in the issue queue as a feature request for ages.

Meh, let's just fix it with a contributed module. That's what I love about modular free and open source software :)

Add new comment

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.