Netlify function cache?

I’m seeing a behaviour where when I curl to a netlify function endpoint I am getting what I assume to be a cached response back from my node js function.

(I only have one function)

Could this be a caching issue? I can change the payload in my request and get the same response back that I had with the original payload

this doesn’t happen locally…

Any tips? do I need to change the cache response in the function? or a cache header in the request? both? (can’t see anything about this in docs)

Thanks

(case with Netlify Support (99504) )

Hi @fentonfentonfenton,

We’ve responded to this in the helpdesk.

Turns out that lambda functions (and therefore netlify functions) run everything outside the handler only once (on the first call)

subsequent calls only run what is inside the handler

so… an api call that i had extracted outside the handler was only running on the first invocation resulting in weird behaviour for me. i moved this into the handler to solve the problem for me.

Thanks for coming back and sharing your solution-- it will definitely help future Forums members who encounter something similar! Glad everything is working now. Happy building :rocket: