Skip to content

We can’t find products matching the selection – Cached (Varnish) M2.4.5

In rare cases we have category pages showing “We can’t find products matching the selection” while actually the category contains products. This happens when the category is visited while Elasticsearch is doing a reindex. The empty page with the message is then cached instead of the page containing products. If we manually remove the page from cache it is showing products again. While this might be expected behaviour (Varnish just caches the page), I would like to know if someone has an idea on how to fix this. For example, could we let Cache/Varnish skip pages that contain this message?