Storage
Overview
How nuxt-unleash caches feature flags across different runtimes.
How It Works
nuxt-unleash caches feature flag data from your Unleash Proxy using a stale-while-revalidate strategy:
First request
On server startup (or first request with an empty cache), the module fetches flags synchronously from the Unleash Proxy and stores them.
Subsequent requests
Each request reads flags from the cache. If the cache is fresh (younger than refreshInterval), flags are returned immediately with no network call.
Stale cache
If the cache is older than refreshInterval, the current (stale) flags are returned immediately and a background refresh is triggered. The next request gets fresh data.
Deduplication
A lock prevents multiple concurrent requests from triggering multiple refreshes. Only one fetch runs at a time.
Storage Backends
Choose a storage backend based on your deployment target:
| Backend | Best for | Persistence | Config |
|---|---|---|---|
| NuxtHub | Cloudflare Workers via NuxtHub | KV store | storage: 'nuxthub' |
| Nitro | Custom drivers (CF KV, Redis, etc.) | Driver-dependent | storage: 'nitro' |
| Memory | Development, simple Node.js | In-process only | storage: 'memory' |
NuxtHub is the recommended backend. It provides persistent KV storage that works across Cloudflare Workers invocations with zero configuration.