You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All HTML routes get a cache-control: public, max-age=0, must-revalidate header from Cloudflare. For our pages statically generated during build this is fine. Cloudflare's CDN and caching mechanism has us covered. For pages that are rendered during runtime the responses will be slower and will hit the underlying services (like DatoCMS) more. We can improve that performance by adding caching headers in an Incremental Static Rendering (ISR) pattern. This blog post explains this pattern using Astro and Cloudflare well: https://logsnag.com/blog/implementing-isr-in-astro
In short, on routes we want to add caching to we can do something like this:
---// Set Cache-Control headers for CDN cachingAstro.response.headers.set('Cache-Control', 'public, s-maxage=60, stale-while-revalidate=30');---
And we could add a helper to set that header (as lib or more conveniently on Astro.locals as we need access to the Astro object), like so: (Astro.locals.)setCache({ seconds: 60 }).
The text was updated successfully, but these errors were encountered:
All HTML routes get a
cache-control: public, max-age=0, must-revalidate
header from Cloudflare. For our pages statically generated during build this is fine. Cloudflare's CDN and caching mechanism has us covered. For pages that are rendered during runtime the responses will be slower and will hit the underlying services (like DatoCMS) more. We can improve that performance by adding caching headers in an Incremental Static Rendering (ISR) pattern. This blog post explains this pattern using Astro and Cloudflare well: https://logsnag.com/blog/implementing-isr-in-astroIn short, on routes we want to add caching to we can do something like this:
And we could add a helper to set that header (as lib or more conveniently on
Astro.locals
as we need access to theAstro
object), like so:(Astro.locals.)setCache({ seconds: 60 })
.The text was updated successfully, but these errors were encountered: