We Need To Talk About Vercel
[Lee from Vercel] Max reached out to me today (Sunday) after this experience, and I worked with him this evening get to a resolution for his site on the Vercel free tier.<p>I&#x27;m really sorry we weren&#x27;t able to get to a resolution faster. I&#x27;ve concluded it&#x27;s not an issue with the Vercel Edge Network based on the reproduction he provided and pushed documentation and example updates (see below). I know Max spent a lot of time on this with back and forth, so I just want to say again how much I appreciate the feedback and helpfulness by providing a reproduction.<p>Here are the full details from the investigation:<p>- Beginning Context: Vercel supports Astro applications (including support for static pages, server-rendered pages, and caching the results of those pages). Further, it supports caching the responses of &quot;API Endpoints&quot; with Astro. It does this by using an adapter[1] that transforms the output of Astro into the Vercel Build Output API[2]. Basically, Astro apps should &quot;just work&quot; when you deploy.<p>- The article states that to update SWR `cache-control` headers you need to use the `headers` property of `vercel.json`[3]. This is for changing the headers of static assets, not Vercel Function responses (Serverless or Edge Functions). Instead, you would want to set the headers on the response itself. This code depends on the framework. For Astro, it&#x27;s `Astro.response.headers.set()`[4]. This correctly sets the response SWR headers.<p>- Vercel&#x27;s Edge Network does respect `stale-while-revalidate`, which you can validate here[5] on the example I created based on this investigation. This example is with `s-maxage=10, stale-while-revalidate`. Vercel&#x27;s Edge strips `s-maxage` and `stale-while-revalidate` from the response. To understand if it&#x27;s a cache HIT&#x2F;MISS&#x2F;STALE, you need to look at `x-vercel-cache`. I appreciate Max&#x27;s feedback here the docs could be better—I&#x27;ve updated the Vercel docs now to make this more clear[6].<p>- I&#x27;ve started a conversation with the Astro team to see how we can better document and educate on this behavior. In the meantime, I updated the official Vercel + Astro example to demonstrate using SWR caching headers based on this feedback[7].<p>- The reproduction provided by Max[8] does not show the reported issue. I was not able to reproduce, which is the same result that our support team saw. It sounds like there were some opportunities for better communication here from our team and I apologize for that. I will chat with them. Free customer or not, I want to help folks have the best experience possible on Vercel. If Max (or anyone else) can reproduce this, I am happy to continue investigating.<p>[1]: <a href="https:&#x2F;&#x2F;docs.astro.build&#x2F;en&#x2F;guides&#x2F;integrations-guide&#x2F;vercel&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.astro.build&#x2F;en&#x2F;guides&#x2F;integrations-guide&#x2F;vercel...</a><p>[2]: <a href="https:&#x2F;&#x2F;vercel.com&#x2F;docs&#x2F;build-output-api&#x2F;v3" rel="nofollow">https:&#x2F;&#x2F;vercel.com&#x2F;docs&#x2F;build-output-api&#x2F;v3</a><p>[3]: <a href="https:&#x2F;&#x2F;vercel.com&#x2F;docs&#x2F;concepts&#x2F;projects&#x2F;project-configuration#headers" rel="nofollow">https:&#x2F;&#x2F;vercel.com&#x2F;docs&#x2F;concepts&#x2F;projects&#x2F;project-configurat...</a><p>[4]: <a href="https:&#x2F;&#x2F;docs.astro.build&#x2F;en&#x2F;reference&#x2F;api-reference&#x2F;#astroresponse" rel="nofollow">https:&#x2F;&#x2F;docs.astro.build&#x2F;en&#x2F;reference&#x2F;api-reference&#x2F;#astrore...</a><p>[5]: <a href="https:&#x2F;&#x2F;astro.vercel.app&#x2F;ssr-with-swr-caching" rel="nofollow">https:&#x2F;&#x2F;astro.vercel.app&#x2F;ssr-with-swr-caching</a><p>[6]: <a href="https:&#x2F;&#x2F;vercel.com&#x2F;docs&#x2F;concepts&#x2F;edge-network&#x2F;caching#server" rel="nofollow">https:&#x2F;&#x2F;vercel.com&#x2F;docs&#x2F;concepts&#x2F;edge-network&#x2F;caching#server</a><p>[7]: <a href="https:&#x2F;&#x2F;github.com&#x2F;vercel&#x2F;vercel&#x2F;pull&#x2F;9778">https:&#x2F;&#x2F;github.com&#x2F;vercel&#x2F;vercel&#x2F;pull&#x2F;9778</a><p>[8]: <a href="https:&#x2F;&#x2F;github.com&#x2F;maxcountryman&#x2F;astro-trpc-example">https:&#x2F;&#x2F;github.com&#x2F;maxcountryman&#x2F;astro-trpc-example</a>