Cache problem in production mode

We have a solution where customer specific content needs to be shown in the product box on the listing page. We searched the internet and found a possible solution (link) which we used as a base.
We created a subscriber to the ProductListingRouteCacheKeyEvent event and added the customer number (when logged in) to the hash key. In dev mode this is working perfect but in the prod mode the boxes are still cached.

Our code:

Blokcitaat
public static function getSubscribedEvents(): array
{
return [
ProductListingResultEvent::class => ‚onProductListingResultEvent‘,
ProductListingRouteCacheKeyEvent::class => ‚addCustomerCachePart‘,
];
}
/**
* @param ProductListingResultEvent $event
* @return void
/
public function onProductListingResultEvent(ProductListingResultEvent $event): void
{
foreach ($event->getResult() as $product) {
if($event->getSalesChannelContext()->getCustomer()) {
$aangemeld = 'Aangemeld: ’ . date(‚Ymd G:i:s‘);
$product->addExtension(‚extraPaginaInfo‘, new ArrayEntity([‚ingelogd‘ => $aangemeld]));
}
else {
$nietAangemeld = 'Niet aangemeld: ’ . date(‚Ymd G:i:s‘);
$product->addExtension(‚extraPaginaInfo‘, new ArrayEntity([‚ingelogd‘ => $nietAangemeld]));
}
}
}
/
*
* @param ProductListingRouteCacheKeyEvent $event
* @return void
*/
public function addCustomerCachePart(ProductListingRouteCacheKeyEvent $event)
{
if($event->getContext()->getCustomer()) {
$customerNumber = $event->getContext()->getCustomer()->getCustomerNumber();
$event->addPart($customerNumber);
}
}

Any help is appreciated.

Hi.

Currently having the same problem. Did you found a solution for this?

Hi,

I’m also experiencing this issue. I found that the http_cache invalidation rules for ‚logged-in‘ and ‚cart-filled‘ are working in ‚dev‘ mode but when i enable ‚prod‘ mode everything gets cached. Regardless of the login state.
@jeroen_treshold_nl did you find a solution?

PS: I also submitted an issue to Github: http_cache invalidation issue in production mode · Issue #4739 · shopware/shopware · GitHub