Vercel Cache - headers are ignored?

I have the problem with Nuxt 3 and Vercel, that I want to exclude some paths from caching. I tried out different Cache control headers, but somehow every request get’s cached.

Here are my headers: "Cache-Control": "private, no-cache, no-store, must-revalidate", . In the screenshot, you can see that we always get a HIT and the age is increasing with every page refresh. Thus, my headers are ignored.

Which headers shall I use to exclude those pages from the edge cache?

Hey Alexander, the cache settings can be persistent sometimes and fail to show updates right away. In any case, we have a couple targeted cache control headers that you can use to ensure your settings take precedent over any defaults. Check out this doc for more details.

The headers are CDN-Cache-Control and Vercel-CDN-Cache-Control. They work the same way, just with a different priority. I think this should help solve your issue, but let me know if not!

1 Like

@pbzona Thank you for your fast answer.

I have already tested it back then and now again with the following headers:

const noStoreHeaders = {
  "Cache-Control": "private, no-cache, no-store, must-revalidate, max-age=0, s-maxage=0",
  "CDN-Cache-Control": "private, no-cache, no-store, must-revalidate, max-age=0",
  "Vercel-CDN-Cache-Control": "private, no-cache, no-store, must-revalidate, max-age=0",
  "Pragma": "no-cache",
  "X-Debug-Isr": "disabled",
};

But it’s not working. I still get the “HIT”. Do you have any ideas?

Hi @alexba, is this happening on all routes or just the sitemap.xml?

Can you share your public repo or a minimal reproducible example. That will let us all work together from the same code to figure out what’s going wrong.

I think this is happening for all routes. I had the same problem with all /api routes.

I will try to create an example in the next couple of days. But it’s just Nuxt 3 with the routeRules in the nuxt.config.js

1 Like

Thanks for sharing. Feel free to share here when you do.