digital-resources icon indicating copy to clipboard operation
digital-resources copied to clipboard

Improve caching with Incremental Static Regeneration (ISR) on Netlify

Open ViorelMocanu opened this issue 6 months ago • 0 comments

https://developers.netlify.com/guides/how-to-do-advanced-caching-and-isr-with-astro/

---
Astro.response.headers.set("Cache-Control", "public, max-age=300, s-maxage=3600");
// Sets the number of seconds to cache the page in the ☝️ browser and ☝️ the CDN
---

for slow to render pages, consider using:

---
// Tell the browser to always check the freshness of the cache
Astro.response.headers.set("Cache-Control", "public, max-age=0, must-revalidate");

// Tell Netlify's CDN to treat it as fresh for 5 minutes, then for up to a week return a stale version
// while it revalidates. Use Durable Cache to minimize the need for serverless function calls.
Astro.response.headers.set(
  "Netlify-CDN-Cache-Control", "public, durable, s-maxage=300, stale-while-revalidate=604800"
);
---

ViorelMocanu avatar Aug 11 '24 13:08 ViorelMocanu