digital-resources
digital-resources copied to clipboard
Improve caching with Incremental Static Regeneration (ISR) on Netlify
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"
);
---