23

I see there are cache settings in each of my views. Do I need to set these or does the core caching mechanisms in /admin/config/development/performance automatically do some of this and these "extra settings" in views are if I want to override the default caching behavior of drupal core?

enter image description here

  • I am curious about this exact question. Do the Views specific cache settings override the Drupal Core performance caching settings? Logically, I would think they it would be the case, but that cannot necessarily be assumed. – David Csonka Mar 5 '12 at 20:01
  • I started a bounty for this, because I really would like to understand this better. – David Csonka Mar 5 '12 at 20:05
38
+50

WHAT: Core performance caching stores and serves the whole rendered page with a cache id of the URL. Views caching goes beyond this to cache just the view output.

WHY: It's great for logged in users; other blocks on the page may be more dynamic but the view doesn't have to run a query every time for every user... just the occasional user who generates the page cache upon cache lifetime expire.

SETTINGS: Allowing the "rendered output" to be fresher than the query is useful for things like marking content as new, otherwise just match them up.

BIG PICTURE: Drupal serves page dynamically, using a server to build pages in PHP and access a database (or in-memory cache). This allows awesome features and content editor velocity... but the trade off is needing to understanding caching and do it right.

MODULES!

There's also a lovely Views Content Cache module which clears views cache on content edit. If you want to go further you may want to check out Cache Actions as well, I'd recommend Rules to fine tune this.

Additionally, Blockcache Alter allows you to set "per role", page, user, etc. caching options for each block on your site.

You can also add Page manager and Panels. This allows you to do interesting things like setting the cache "per user", "per role", or a number of other very useful configurations. Though I personally avoid panels.

DOCUMENTATION: For caching and performance in general check out the Drupal.org page.

  • This answer is really good. Up-voted. I added a section on Page manager and Panels, and now the answer could be mostly complete. – Letharion Mar 5 '12 at 21:00
  • Does Core Performance "Block caching" need to be enabled for the Views specific caching to work? – David Csonka Mar 5 '12 at 21:05
  • Thanks for adding the bit about Page manager/Panels - because after adding the bounty for this I realized I was also curious about Mini-panels caching. I was wondering if Core Performance "Block caching" overrides or was required to be enabled in order for Mini-Panels "Simple caching" to be effective. – David Csonka Mar 5 '12 at 21:08
  • 1
    Block caching would indeed cache the block output regardless of your views caching settings... same as the page cache. If you have a 12 hour logged out page cache lifetime, the view cache doesn't matter because those pages aren't being rendered again, they're just getting served from cache. – doublejosh Mar 6 '12 at 7:23
  • 1
    On the versa side, if I enable Core Block caching, Drupal will impose the same caching conditions on all of my blocks throughout my entire site, right? Since Core Drupal Block Caching takes high priority over the Views Block caching settings? That seems like only a good scenario if you don't have content which may need to be refreshed on a consistent basis. – David Csonka Mar 7 '12 at 17:19
4

Views uses the Drupal cache APIs but it creates its own cache that isn't related to the normal Drupal page/block cache.

Views caches the view definition itself along with the rendered view itself. The rendered view can be cached in two ways, either the query result or the actual HTML of the view. Normally you want to cache the outputted HTML since this is the most performance effective. In some cases where you want to alter the output based on the logged in user, caching the query can be quite effective as well.

The tables Views uses for storing the cache is:

  • cache_views
  • cache_views_data
  • So, can I disable the Drupal Core Block caching setting at admin/config/development/performance, but enable specific Views display block caches individually, and still have those Views block caches work properly? – David Csonka Mar 6 '12 at 21:07
  • 1
    @DavidCsonka Yes you can do that. Caching the block would be more effective than caching the view, but only by a small margin. – googletorp Mar 7 '12 at 11:56
  • Ahh, that's good to know. But, using just the Views caching settings would give me more precise control over how the Views block is cached, right? If I use the Core Block Caching instead, it basically imposes one set of caching settings on every block in my site? Correct? – David Csonka Mar 7 '12 at 17:17
  • 1
    Views caching (block or page) gives you control over the caching of the result list set. Block caching is about the full block output. Yes core block caching is a site-wide setting but you can use Block Cache Alter to alter that very granularly per block. – doublejosh Mar 7 '12 at 21:38
  • 3
    @doublejosh In Drupal 7 you can define how the block cache should work, site-wide, per role, per page, page user is the options I believe. Since it's caching at a higher level, it's more performance effective. – googletorp Mar 8 '12 at 10:24
3

There is an interesting module now available called views cache bully that automatically caches all views (query results and output), except for views with exposed forms. The module also allows you to manually exclude views from its caching. This makes it possible set caching for all views (except those excluded) from a central point.

2

Drupal 7 provides page caching however page caching only works for anonymous users and does not cache views

Views caching however works for both anonymous and logged in users

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.