diff options
Diffstat (limited to 'packages/integrations/netlify/README.md')
-rw-r--r-- | packages/integrations/netlify/README.md | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/packages/integrations/netlify/README.md b/packages/integrations/netlify/README.md index 18ba65cd7..39f7e148f 100644 --- a/packages/integrations/netlify/README.md +++ b/packages/integrations/netlify/README.md @@ -162,6 +162,30 @@ Once you run `astro build` there will be a `dist/_redirects` file. Netlify will > **Note** > You can still include a `public/_redirects` file for manual redirects. Any redirects you specify in the redirects config are appended to the end of your own. +### On-demand Builders + +[Netlify On-demand Builders](https://docs.netlify.com/configure-builds/on-demand-builders/) are serverless functions used to generate web content as needed that’s automatically cached on Netlify’s Edge CDN. You can enable their use, using the [`builders` configuration](#builders). + +By default, all pages will be rendered on first visit and the rendered result will be reused for every subsequent visit until you redeploy. To set a revalidation time, call the [`runtime.setBuildersTtl(ttl)` local](https://docs.astro.build/en/guides/middleware/#locals) with the duration (in seconds). + +As an example, for the following snippet, Netlify will store the rendered HTML for 45 seconds. + +```astro +--- +import Layout from '../components/Layout.astro'; + +if (import.meta.env.PROD) { + Astro.locals.runtime.setBuildersTtl(45); +} +--- + +<Layout title="Astro on Netlify"> + {new Date(Date.now())} +</Layout> +``` + +It is important to note that On-demand Builders ignore query params when checking for cached pages. For example, if `example.com/?x=y` is cached, it will be served for `example.com/?a=b` (different query params) and `example.com/` (no query params) as well. + ## Usage [Read the full deployment guide here.](https://docs.astro.build/en/guides/deploy/netlify/) @@ -206,7 +230,7 @@ directory = "dist/functions" ### builders -[Netlify On-demand Builders](https://docs.netlify.com/configure-builds/on-demand-builders/) are serverless functions used to build and cache page content on Netlify’s Edge CDN. You can enable these functions with the `builders` option: +You can enable On-demand Builders using the `builders` option: ```js // astro.config.mjs |