Cache Command
Manage the build-time request cache from the CLI.
The multitenant cache command helps you manage the build-time request cache (for both cachedFetch and Contentful SDK), view statistics, and invalidate cached data by locale.
The cache files live at .next/.build-cache/locales/{locale}/ and are managed uniformly whether they come from @multitenant/next-app's cachedFetch (REST API calls) or @multitenant/contentful's SDK wrapper (Contentful SDK calls).
Usage
multitenant cache [options]Options
| Option | Type | Description |
|---|---|---|
--stats | flag | Print cache statistics (entry counts, last modified time per locale) |
--locale <locale> | string | Invalidate specific locale(s) (repeatable, or use all) |
--cache-dir <dir> | string | Custom cache directory (default: .next/.build-cache) |
--cwd <dir> | string | Working directory (default: current directory) |
--help | flag | Show help message |
Examples
View Cache Statistics
multitenant cache --statsOutput:
Cache stats (.next/.build-cache):
en-US: 42 entries, last cached 2026-04-03T10:30:45.123Z
es-US: 38 entries, last cached 2026-04-03T10:31:12.456Z
Total: 80 entriesInvalidate Single Locale
multitenant cache --locale en-USOutput:
Invalidated cache for locale: en-USInvalidate Multiple Locales
multitenant cache --locale en-US --locale es-US --locale fr-CAOutput:
Invalidated cache for locale: en-US
Invalidated cache for locale: es-US
Invalidated cache for locale: fr-CAInvalidate All Locales
multitenant cache --locale allOutput:
Invalidated cache for all localesCommon Workflows
Before Production Deploy
# View current cache size
multitenant cache --stats
# Invalidate caches for markets that changed content
multitenant cache --locale en-US --locale es-US
# Rebuild with fresh data
npm run buildCMS Webhook Integration
Create a webhook in your CMS (Contentful, Sanity, etc.) that calls:
multitenant cache --locale all && npm run buildThis ensures your site always builds with the latest CMS data.
Development: Clear All Caches
multitenant cache --locale allCache Location
By default, cache is stored at .next/.build-cache/. To use a custom location:
multitenant cache --stats --cache-dir .cache/build
multitenant cache --locale all --cache-dir .cache/build