netlify-plugin-ttl-cache

A Netlify plugin for persisting immutable build assets across releases.

Usage no npm install needed!

<script type="module">
  import netlifyPluginTtlCache from 'https://cdn.skypack.dev/netlify-plugin-ttl-cache';
</script>

README

Netlify plugin TTL cache

A Netlify plugin for persisting immutable build assets across releases.

How it works

By default, Netlify replaces all existing static assets when publishing new releases.

For sites where assets are unique across deployments, and dynamically loaded (e.g. React.lazy) this can lead to runtime errors (e.g. chunk-load errors).

This plugin prevents this problem by allowing users to include legacy assets across releases.

Usage

Install the plugin

npm i -D netlify-plugin-ttl-cache

Add the plugin to your netlify.toml

[[plugins]]
package = "netlify-plugin-ttl-cache"
  [plugins.inputs]
  path = "build"
  ttl = 90

Inputs

path

Build output directory.

type: string

default: "build"

ttl

Maximum age (days) of files in cache.

type: number

default: 90

exclude

Regular expression string pattern for files to exclude.

type: string

default: n/a