Hi @accounts,
Great question!
First, a disclaimer: I am not an expert on this; if anyone knows better (@m.finamor, maybe?), please chime inā¦
Vercel alternative: Use time-based ISR instead?
I donāt believe Astro can use cache tags on Vercel; as far as I can tell, Vercelās CDN doesnāt allow generic tag-based revalidations across frameworks. (Yes, Vercel can do tag-based invalidation with Next.js, but thatās because itās built into the Next.js framework and not their CDNā¦ maybe they have some internal APIs that Next uses but that arenāt exposed to the general public or Astro? You can double-check with their support too).
However, Vercel does support time-based ISR on Astro: https://vercel.com/docs/frameworks/astro#incremental-static-regeneration.
To your users, this should function similarly: They still get the performance benefits of statically built pages, and Vercel processes the invalidations & rebuilds in the background.
To you (as the developer), I think the primary downside is more API calls, since every revalidation check will have to query our API ā but still less than serverside rendering would use, uncached. Serverside rendering would typically query our API on every page load, while static generation would limit that to once per revalidation period. If a page were set to isr: {expiration: 60} // in seconds
, it would make at most one revalidation check per minute to our API.
Other options: Hosting providers that support tag-based invalidation
If you absolutely want cache tags, is Vercel the only option? Netlify has a similar one-click deploy workflow, and their CDN does natively support cache tags: https://developers.netlify.com/guides/how-to-do-advanced-caching-and-isr-with-astro/#on-demand-revalidation-with-cache-tags or read their blog writeup that explains how it works.
Thatās basically the missing piece on Vercel. Fameworks other than Next.js have no way to ask Vercel āplease invalidate your cache for objects _____, _____, and ______ā. Next.js has the revalidateTag()
function internally, but I could find nothing like that in the Vercel API outside of Next. Netlify and Fastly both provide an API for that, which is what makes cache tags work there.
There are many other CDNs that support cache tags, like GCP, AWS, Bunny.net, Cloudflare (for enterprise only), etc. Hopefully Vercel will someday, too!