Multitenant

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

OptionTypeDescription
--statsflagPrint cache statistics (entry counts, last modified time per locale)
--locale <locale>stringInvalidate specific locale(s) (repeatable, or use all)
--cache-dir <dir>stringCustom cache directory (default: .next/.build-cache)
--cwd <dir>stringWorking directory (default: current directory)
--helpflagShow help message

Examples

View Cache Statistics

multitenant cache --stats

Output:

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 entries

Invalidate Single Locale

multitenant cache --locale en-US

Output:

Invalidated cache for locale: en-US

Invalidate Multiple Locales

multitenant cache --locale en-US --locale es-US --locale fr-CA

Output:

Invalidated cache for locale: en-US
Invalidated cache for locale: es-US
Invalidated cache for locale: fr-CA

Invalidate All Locales

multitenant cache --locale all

Output:

Invalidated cache for all locales

Common 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 build

CMS Webhook Integration

Create a webhook in your CMS (Contentful, Sanity, etc.) that calls:

multitenant cache --locale all && npm run build

This ensures your site always builds with the latest CMS data.

Development: Clear All Caches

multitenant cache --locale all

Cache 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

See Also

On this page