Static local images using next/image returning max-age=0

Netlify Image CDN is not respecting the cache-control headers unexpectedly returning public,max-age=0,must-revalidate for static local images, whereas NextJS is correctly returning public, max-age=315360000, immutable

Screenshot 2024-04-29 at 5.23.04 PM

sweelee-experience.netlify.app

Is there a way to configure or fix this?

Where is it returning this?

Also, don’t do this.

It can be seen in local development

Have you referred to: Netlify Image CDN | Netlify Docs?

thanks for the reply @hrishikesh, the following config works but I would like to know why the Image CDN is not respecting with NextJS defaults

[[headers]]
  for = "/_next/static/*"
  [headers.values]
    Cache-Control = "public, max-age=604800, immutable"

Image CDN needs its own headers. Next.js config will only work when Next.js server serves the images and that doesn’t happen with the Image CDN.

Static assets are all the files that don’t invoke a Function or an Edge Function. I don’t think we’re treating local assets are dynamic. The cache-control as you can see always has a max-age 0. The Netlify-CDN-Cache-Control header is set internally and not sent to browser, so you won’t be able to see it.

For Image CDN, that’s about right. For Functions, it’s like Request → Netlify CDN → AWS Lambda and then return trip as well.

It directly goes on Image CDN. Functions are not involved here.

@darrelhong why not?