# Cache problem in production mode

**URL:** <https://forum.shopware.com/t/cache-problem-in-production-mode/100466>\
**Category:** Shopware 6 (English)\
**Tags:** general, themes--design\
**Created:** [11. Juli 2023 um 06:47 UTC](https://forum.shopware.com/t/cache-problem-in-production-mode/100466 "2023-07-11T06:47:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeroen\_treshold\_nl](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jeroen\_treshold\_nl](https://forum.shopware.com/u/jeroen_treshold_nl)\
**Post date:** [11. Juli 2023 um 06:47 UTC](https://forum.shopware.com/t/cache-problem-in-production-mode/100466/1 "2023-07-11T06:47:23Z")

</div>

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](https://stackoverflow.com/questions/68286934/shopware-6-changing-url-parameters-returns-the-same-result-in-prod-mode)) 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.

---

<div class="post-metadata">

**Author:** ![\_marco](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/_marco/32/8582_2.png) [@\_marco](https://forum.shopware.com/u/_marco)\
**Post date:** [4. Juli 2024 um 08:55 UTC](https://forum.shopware.com/t/cache-problem-in-production-mode/100466/2 "2024-07-04T08:55:17Z")

</div>

Hi.

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

---

<div class="post-metadata">

**Author:** ![dean](https://avatars.discourse-cdn.com/v4/letter/d/3be4f8/32.png) [@dean](https://forum.shopware.com/u/dean)\
**Post date:** [20. September 2024 um 07:30 UTC](https://forum.shopware.com/t/cache-problem-in-production-mode/100466/3 "2024-09-20T07:30:15Z")

</div>

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](https://github.com/shopware/shopware/issues/4739)
