How to cache on-the-fly generated images in the CDN?

I’m building a Remix blog which I’ve deployed to Netlify. So far so god. Now I want to transform images with sharp from an API route and cache the result in the CDN. The route (/api/image?...) returns the image and the cache-control header 'public, max-age=31536000, s-maxage=31536000', but I always get age=0 in my response headers. I assume that this means that the image gets generated over and over again? If I set s-maxage, shouldn’t this get cached in the CDN? Is there any other option to check for cache hits beside the age response header?


Hi @peter.oesteritz

Could we have a site to check? We have the request ID in the screenshot, but typing that from the image is error prone. So, it would be okay if you can send us the text of that.

Furthermore, age: 0 would mean it was not cached in the CDN node that served it. It could be cached in one of the 70+ other nodes.

Hi @hrishikesh, here’s the link: DENNERLEIN