Facet block adds view max age on every page

Created on 23 June 2023, almost 2 years ago

Problem/Motivation

We noticed that when a facet block from a view with a low max age does not have any condition, the view's max-age is applied to every page even if the facet is not displayed.

Steps to reproduce

  1. Create a search_api view page with a max age of one hour.
  2. Create a facet based on this view and enable "Hide facet when facet source is not rendered".
  3. Add the facet block without any condition.
  4. Now every page has a max age of 3600 seconds.

Proposed resolution

This happens because if the block does not have any condition, then FacetBlock::blockAccess() is always executed and the AccessResult's cache depends on the facet that in turn depends on the view display (which has a 3600 seconds max age).

A workaround is to add a condition to the block to make sure it is only displayed on the view page. (If the condition is false, then FacetBlock::blockAccess() is never called and the max age is not retrieved.) But that kind of defeats the point of the "Hide facet when facet source is not rendered" option.

I am not sure what a correct fix would be, since it seems legitimate that the block access cache depends on the facet's cache metadata.

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇫🇷France prudloff Lille

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

Comments & Activities

Production build 0.71.5 2024