'SSR Cache issue 3.x Version

We have one peculiar issue in SSR rendering. Pages are being served from cache layer from second time in SSR rendering. We want to disable this for certain use cases. E.g If we change the product name in back office and try to access the product in storefront first time we get 301. But next time we get 200. So we always wanted to get 301 when product name gets changed/removed. We tried setting via header this.response.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate'); But it didn't work. Can you please help us with this? #help



Solution 1:[1]

Disabling cache only for certain scenarios is not supported in Spartacus SSR optimization engine, and you would have to write a custom logic to support it.

For 5.0+ version we can consider to make the "return from cache on second render" feature optional. Can you please create a ticket for that on GitHub?

As a side note, it seems like you're using SSR as a live server, which is not recommended. We recommend putting SSR servers / nodes behind a CDN. If CDN caches 301, the requests hitting the CDN will always get 301.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 pegasus