ViorelMocanu / digital-resources

A web-based version of the digital resources document found in https://bit.ly/vio-digital
https://resurse.dev/
ISC License
33 stars 6 forks source link

Improve caching with Incremental Static Regeneration (ISR) on Netlify #300

Open ViorelMocanu opened 2 months ago

ViorelMocanu commented 2 months ago

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"
);
---