How to prevent a specific set-cookie response header from being removed?

How to prevent a specific set-cookie response header from being removed?

We need to remove set-cookie headers from response to enable caching, but at the same time some set-cookie header is needed to get recently view items on product page.
Do we have any option to keep certain set-cookie header in a way like we can remove it here https://docs.layer0.co/docs/api/core/classes/router_responsewriter.responsewriter.html#removeresponsecookie ?

Although it is possible to remove a set-cookie header using the router_responsewriter.responsewriter.html#removeresponsecookie method, caching will be disabled, which you indicate you do not want.

Instead, please use the removeUpstreamResponseHeader method.

Here are additional resources:

  • Method details are here.

  • Example usage is here.