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?
-
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 CsonkaCommented Mar 5, 2012 at 20:01
-
I started a bounty for this, because I really would like to understand this better.– David CsonkaCommented Mar 5, 2012 at 20:05
4 Answers
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. Commented Mar 5, 2012 at 21:00
-
Does Core Performance "Block caching" need to be enabled for the Views specific caching to work? Commented Mar 5, 2012 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. Commented Mar 5, 2012 at 21:08
-
1Block 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. Commented Mar 6, 2012 at 7:23
-
1On 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. Commented Mar 7, 2012 at 17:19
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? Commented Mar 6, 2012 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. Commented Mar 7, 2012 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? Commented Mar 7, 2012 at 17:17
-
1Views 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. Commented Mar 7, 2012 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. Commented Mar 8, 2012 at 10:24
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.
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