Cloudflare caching with Lambda Response Streaming & NextJs Streaming

Hi,

I am trying to develop the NextJS application as Lambda function URL ie enabled with Lambda Response Streaming. Lambda response streaming enables the partial response being sent to the clients and progressively generating the further response and sent to the client. On top of that NextJs also supports the component level streaming.

So wanted to know how Cloudflare caching would affect this. Does cloudflare caches these partial responses separately and how is this sent back to the browser ? Or Cloudflare have any intelligence to cache the pages progressively under the same key?

Do we have do any special configurations to support this?

Can someone please some good insights on this ?

Thanks.

Hello @thefirstscorpion

Cloudflare does not cache partial responses; it waits for the full response before caching. (Cloudflare Cache)

For streaming responses, you’ll need to configure Cloudflare to either bypass the cache or use custom caching rules. (E.g. Set Cache Level to Bypass or set up Custom Caching rules with Edge Cache TTL)

To support streaming with caching, you might consider using Cloudflare Workers to manage how streaming responses are cached and served.

Make sure to test your configuration to ensure it works as expected with your streaming setup.

Thanks @Luis.Cardoso for the detailed response.

Can you please also help me understand, how streamed response passed to the client/browser when we have Cloudflare acts as CDN for lambda url? Will the streamed response be sent to the browser immediately as is, will that be buffered at Cloudflare and then be sent to browser ?

Do we not have any guidelines released from Cloudflare on dealing with streamed response and caching those responses?