0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-13 22:11:20 -05:00
astro/.changeset/sweet-cows-roll.md
Arsh f974c95a27
Add Incremental Static Regeneration support for the Netlify's on-demand builders adapter (#7975)
* feat(netlify): expose builders ttl as a local

* add changeset

* docs(netlify): caching using on-demand builders

* reword readme section

* Update packages/integrations/netlify/package.json

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>

* include builders-types.d.ts in the distribution

* document caveat regarding query params

* update changeset

* mutation -> function

* locals.netlify -> locals.runtime

* update types and changeset

* Apply suggestions from code review

Co-authored-by: Elian ️ <hello@elian.codes>

* Apply suggestions from code review

Co-authored-by: Elian ️ <hello@elian.codes>

---------

Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
Co-authored-by: Elian ️ <hello@elian.codes>
2023-08-11 19:39:44 +05:30

625 B

@astrojs/netlify
minor

If you are using Netlify's On-demand Builders, you can now specify how long your pages should remain cached. By default, all pages will be rendered on first visit and reused on every subsequent visit until a redeploy. To set a custom revalidation time, call the runtime.setBuildersTtl() local in either your frontmatter or middleware.

---
import Layout from '../components/Layout.astro'

if (import.meta.env.PROD) {
    // revalidates every 45 seconds
    Astro.locals.runtime.setBuildersTtl(45)
}
---
<Layout title="Astro on Netlify">
    {new Date(Date.now())}
</Layout>