Incremental Static Regeneration (ISR) allows you to update static pages after deployment without rebuilding your entire site. Pages are statically generated at build time and can be revalidated on-demand or after a specified time period.
ISR combines the performance benefits of static generation with the flexibility of server-side rendering.
Like SSR, ISR pages need prerender: false. The difference is in how caching headers are configured:
src/pages/isr.astro
---import Layout from '@/layouts/Layout.astro'export const prerender = falseconst time = new Date().toLocaleTimeString()---<Layout seo={{ title: 'Incremental Static Regeneration (ISR)', description: 'A page that uses Incremental Static Regeneration (ISR) allows you to create or update content on your site without redeploying', }}> <section> <hgroup> <h2>Incremental Static Regeneration (ISR)</h2> <p> A page that uses Incremental Static Regeneration (ISR) allows you to create or update content on your site without redeploying </p> </hgroup> <h1>{time}</h1> <a href="/isr">Refresh</a> <button id="revalidate">Revalidate</button> </section></Layout><script is:inline> function revalidate() { fetch('/api/revalidate', { method: 'POST', body: JSON.stringify(''), headers: { 'Content-Type': 'application/json', }, }) alert(`Revalidated`) } const revalidateButton = document.querySelectorAll('button#revalidate')[0] revalidateButton.addEventListener('click', () => { revalidate() })</script>