Problem/Motivation

After #2381277: Make Views use render caching and remove Views' own "output caching" Views uses regular Drupal 8 render caching with cache tag support instead of the output cache. However this still needs to be configured manually.

Proposed resolution

Set the 'tags' cache plugin as the default. Additionally update all views shipped with core to use it.

Remaining tasks

Do it.

User interface changes

None.

API changes

None.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Postponed » Needs review
FileSize
96.87 KB

Let's see, this just switches over to tag, but I'm quite convinced that we need some logic to opt out once you have for example an exposed text field.

Status: Needs review » Needs work

The last submitted patch, 1: 2502255-1.patch, failed testing.

effulgentsia’s picture

Issue tags: +D8 cacheability
dawehner’s picture

Status: Needs work » Needs review

Yeah indeed I forgot to pull HEAD .

dawehner’s picture

FileSize
96.39 KB

And here now even with a patch

Status: Needs review » Needs work

The last submitted patch, 5: 2502255-4.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.84 KB
98.92 KB

Render cache item not found. Other RenderCacheIntegrationTest.php 50 Drupal\views\Tests\RenderCacheIntegrationTest->testFieldBasedViewCacheTagsWithCachePluginNone()

Its really convincing that we fail here :)

larowlan’s picture

FileSize
14.32 KB

Here's a diff of all the views yml files in core not updated by this patch

And here's the output of checking each of those for a reference to cache:
more ~/patches/views.do-not-test.diff |grep "^+"|cut -d"+" -f2|while read r;do grep -2i cache --color "./$r" && echo $r;done;

        options:
          perm: 'access content'
      cache:
        type: tag
        options: {  }
core/modules/node/config/optional/views.view.frontpage.yml
status: true
dependencies: {  }
id: test_cache
label: ''
module: views
--
--
      defaults:
        filters: false
        cache: false
      cache:
        type: time
        options:
--
--
          output_lifespan: 3600
      filters:
        test_cache_context:
          id: test_cache_context
          table: views_test_data
--
          table: views_test_data
          field: test_cache_context
          relationship: none
--
          relationship: none
    cache_metadata:
      contexts:
--
      contexts:
        - views_test_cache_context
core/modules/views/tests/modules/views_test_config/test_views/views.view.test_cache.yml
  module:
    - node
id: test_tag_cache
label: ''
module: views
--
--
      access:
        type: none
      cache:
        type: tag
      exposed_form:

As seen by that diff, the views yml files in core not updated to have tag as their default fall into two categories:

  1. those that don't have a cache: entry (and will receive the new default of tag)
  2. those that do, but already specify time or tag

All the others are already updated by this patch

Manual test next, but code review is RTBC in my book

larowlan’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
193.82 KB
51.55 KB

Installed and manually tested a few built in views, looks good to me.

Content admin screen works with exposed filter too

dawehner’s picture

Not convinced by it yet, honestly :)

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

views.do-not-test.diff no longer applies.

error: tmp/modified.txt: No such file or directory

alexpott’s picture

Status: Needs work » Reviewed & tested by the community

Opps automated alex mistake...

xjm’s picture

@dawehner Are you still concerned that there are circumstances where the cache is not invalidated properly?

catch’s picture

@xjm I talked to dawehner in irc and I think his concern was that in the case of exposed text filters (for example) we could end up writing lots of cache entries.

However pagers or just any randomly appended query string can have the same cache-filling effect, so I don't think that's a reason not to do this.

It's something sites need to be aware of, but it's fixed by using an LRU cache backend instead of MySQL, and a pre-existing issue.

effulgentsia’s picture

I also think a contrib module could be written that flags certain query arg contexts (e.g., url.query_args:AN_OPEN_ENDED_TEXT_FILTER) as too open-ended to cache. I don't think core needs to make such optimization opinions though. But, looks to me like HEAD's FilterPluginBase::getCacheContexts() returns just url as the context rather than the specific query arg, so I think that needs to be changed to support such optimization in contrib. Could be a followup though.

dawehner’s picture

I also think a contrib module could be written that flags certain query arg contexts (e.g., url.query_args:AN_OPEN_ENDED_TEXT_FILTER) as too open-ended to cache. I don't think core needs to make such optimization opinions though. But, looks to me like HEAD's FilterPluginBase::getCacheContexts() returns just url as the context rather than the specific query arg, so I think that needs to be changed to support such optimization in contrib. Could be a followup though.

Oh good catch. There used to be a time when we didn't had more specific cache contexts ...

Added a follow up: #2503185: Specify a more specific cache context in FilterPluginBase

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.0.x, thanks!

  • catch committed 68e606c on 8.0.x
    Issue #2502255 by dawehner, larowlan: Enable tags cache plugin by...
Wim Leers’s picture

Issue tags: -Needs reroll

Wow, I didn't realize this had already happened! I should go on vacation more often :D

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.