Views Integration - Consider compatibility with internal page cache

Created on 29 August 2017, almost 7 years ago
Updated 18 February 2023, over 1 year ago

After #2753667: Improve Views cache plugin(s) and their cache metadata β†’ we have a search-api-specific views cache plugin that uses a search_api_list:[index] cache tag for invalidation. When this cache plugin is active, that tag helps invalidate the cached views data and bubbles-up to help with invalidation on page-level caching (internal and dynamic page caches). This is great.

However it may be best practice to disable views caching for certain search-api DB backends, such as solr. In this case the best choice would be the "None" views cache plugin, which sets no additional cache tags and sets a max-age of 0 to disable caching. The problem here is that the internal page cache ignores max-age and depends exclusively on tags for invalidation. As search api does not seem to add any content or index-specific tags to views output by default some views can end up in the internal page cache with no useful invalidation criteria, leading to permanently stale data. I assume this is a fairly common problem given that the internal page cache is enabled by default.

Perhaps it would be useful to add the search_api_list:[index] cache tag to views output unconditionally? It would appear that "standard" content views do something like this by always adding the node_list tag independent of the views cache plugin. This could allow for some "fallback" invalidation criteria that would otherwise have no impact for any caching layers that do respect a max-age setting of 0. This would of course not help with more complex caching situations that may simply be incompatible with the internal page cache (like asynchronous indexing in solr) but it could help produce more expected caching behavior for many other cases.

I suppose that this issue is tangled up in many other layers outside of search API (e.g #2499321 β†’ and #2352009 β†’ ), so this may not be nearly as straightforward as I think.

✨ Feature request
Status

Fixed

Version

1.0

Component

Views integration

Created by

πŸ‡ΊπŸ‡ΈUnited States rjacobs

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡±Netherlands idebr

    My apologies for the comment in #13. I scanned the related issue without checking for the implementation of cache tags. In fact, there is explicit test coverage that shows the index list tag is missing for the 'None' plugin in ViewsDisplayCachingTest.

    I agree with #12 that adding the list tag on the query is the preferred approach here, since it saves us the headache of adding an upgrade path for existing Search API views that use the existing None plugin.

    Attached patch implements the following changes compared to #6:

    1. Adds test coverage to check the search_api_list cache tag is added when using the 'None' cache plugin
    2. Removed the getCacheTags implementation on the Search API Tag cache plugin, as its tags are now available through the SearchApiQuery

    ViewsDisplayCachingTest still passes without changes to the Search API Time cache plugin, so it appears it is not necessary to remove the list tag again as suggested in #12

  • πŸ‡³πŸ‡±Netherlands idebr

    Attached patch implements the following changes:

    1. Updated assertions for existing tests to include the list cache tag.
    2. Turns out the Search API Time-based cache plugin needs to removed the list cache tag after all.
  • Status changed to RTBC over 1 year ago
  • πŸ‡³πŸ‡±Netherlands Lendude Amsterdam

    Tested on our project and the correct search_api_list cache tag now gets added to all pages that show Search API generated Views.

  • Status changed to Needs review over 1 year ago
  • πŸ‡¦πŸ‡ΉAustria drunken monkey Vienna, Austria

    Thanks, great work! Also thanks @Lendude for testing.
    Just two tiny corrections – if the test bot is happy with those then I’ll commit.

  • Status changed to Fixed over 1 year ago
  • πŸ‡¦πŸ‡ΉAustria drunken monkey Vienna, Austria

    Committed.
    Thanks a lot again, everyone!

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

Production build 0.69.0 2024