Can I have the app router set Cache-Control with a max-age > 0?
Unanswered
Upland Sandpiper posted this in #help-forum
Upland SandpiperOP
I'm running Vercel behind Cloudflare and would like CF to prevent scraping and also cache some of my static pages. At the moment, however, it looks like all the Vercel responses are sent out with
max-age=0, even though all the fetch requests in the app have {next: revalidate: 10000}. I assumed that Next would derive a cache lifetime from that cache info - is there a more explicit way to set it?5 Replies
@Upland Sandpiper I'm running Vercel behind Cloudflare and would like CF to prevent scraping and also cache some of my static pages. At the moment, however, it looks like all the Vercel responses are sent out with `max-age=0`, even though all the `fetch` requests in the app have `{next: revalidate: 10000}`. I assumed that Next would derive a cache lifetime from that cache info - is there a more explicit way to set it?
try either
headers() in next.config.js or setting header in middlewareUpland SandpiperOP
Both of those are being overwritten by next, according to the docs?
Oh really? Could you give me the source
Upland SandpiperOP
@Upland Sandpiper Hm, https://nextjs.org/docs/app/api-reference/next-config-js/headers#cache-control
Oh wow. How about middleware?