View on GitHubView PackagePublished: Jun 22, 2026

Release Notes

Major Changes

Minor Changes

  • #16335 9a53f77 Thanks @ascorbic! - Adds a CDN cache provider for Astro route caching on Netlify

    Setup

    Import cacheNetlify() from @astrojs/netlify/cache and set it as your cache provider:

    import { defineConfig } from 'astro/config';
    import netlify from '@astrojs/netlify';
    import { cacheNetlify } from '@astrojs/netlify/cache';
    
    export default defineConfig({
      adapter: netlify(),
      cache: {
        provider: cacheNetlify(),
      },
    });
    

    Caching responses

    Use Astro.cache.set() in your pages and API routes to cache responses on Netlify's edge network. The provider uses Netlify's durable cache so cached responses are shared across all edge nodes, reducing function invocations.

    ---
    Astro.cache.set({ maxAge: 300, tags: ['products'] });
    const data = await fetchProducts();
    ---
    
    <ProductList items={data} />
    

    You can also set cache rules for groups of routes in your config:

    cache: { provider: cacheNetlify() },
    routeRules: {
      '/products/[...slug]': { maxAge: 3600, tags: ['products'] },
      '/api/[...path]': { maxAge: 60, swr: 600 },
    },
    

    Invalidation

    Purge cached responses by tag or path from any API route or server endpoint:

    // src/pages/api/purge.ts
    export async function POST({ request, cache }) {
      await cache.invalidate({ tags: ['products'] });
      return new Response('Purged');
    }
    
    // Path-based invalidation
    await cache.invalidate({ path: '/products/123' });
    

    Both tag-based and path-based invalidation are supported.

Patch Changes