1. Home
  2. ChevronRightAdvanced
  3. ChevronRightCache & Environment

Cache & Environment

How Boltdocs caching works, what gets cached, and the environment variables that control it.

Boltdocs caches parsed files and transformations to make subsequent builds and dev server restarts fast. This guide covers how the cache works and how to configure it.


How Caching WorksLink

Boltdocs uses a multi-layer caching system:

  1. Memory LRU Cache — Fast in-process cache for hot data
  2. Disk Cache — Persisted to .boltdocs/ directory (organized under .boltdocs/cache/, .boltdocs/build/, .boltdocs/generated/, .boltdocs/reports/) for reuse across restarts
  3. Invalidation — Automatic based on file mtime and content hash

What Gets CachedLink

Cache TypeWhat's StoredLocation
Parser CacheFrontmatter, headings, metadata for each .md/.mdx file.boltdocs/cache/parser/
MDX TransformCompiled MDX code for each file.boltdocs/cache/mdx/
Route CacheBuilt route objects with all metadata.boltdocs/cache/routes/

Cache BehaviorLink

Development ModeLink

  • Cache is loaded on startup for instant navigation
  • Files are watched — changes invalidate relevant cache entries
  • Full rebuild only when config or plugins change

Production BuildLink

  • Cold start builds from scratch
  • Cache written to disk for future use
  • CI/CD environments get consistent builds

Environment VariablesLink

Configure caching behavior via environment variables:

VariableTypeDefaultDescription
BOLTDOCS_CACHE_DIRstring.boltdocs/cacheDirectory for core processing cache files
BOLTDOCS_NO_CACHEbooleanfalseSet to 1 to disable all caching
BOLTDOCS_CACHE_LRU_LIMITnumber2000Max entries in memory LRU cache
BOLTDOCS_CACHE_LRU_TTLnumber14400000TTL in ms (default 4 hours)
BOLTDOCS_CACHE_COMPRESSbooleantrueEnable gzip compression for cache files

Integration Environment VariablesLink

In addition to caching options, Boltdocs resolves integration-specific keys from your environment variables securely:

VariableScopeDescription
BOLTDOCS_GITHUB_TOKENCustom FeedbackA personal access token (PAT) with write access to GitHub Discussions.
BOLTDOCS_GITHUB_REPO_OWNERCustom FeedbackOverrides the target repository owner username or organization.
BOLTDOCS_GITHUB_REPO_NAMECustom FeedbackOverrides the target repository name.
GITHUB_APP_IDGitHub App AuthThe unique App ID generated by your GitHub App.
GITHUB_PRIVATE_KEYGitHub App AuthThe RSA private key of the GitHub App.
GITHUB_INSTALLATION_IDGitHub App AuthThe installation ID associated with your target repository.

Usage ExamplesLink

# Disable all caching (useful for debugging)
BOLTDOCS_NO_CACHE=1 pnpm docs:dev

# Use custom cache directory
BOLTDOCS_CACHE_DIR=.cache/boltdocs pnpm docs:dev

# Increase cache size for large projects
BOLTDOCS_CACHE_LRU_LIMIT=5000 pnpm docs:dev

Cache InvalidationLink

The cache automatically invalidates when:

  1. File content changes — Detected via content hash
  2. File is deleted — Cache entry removed
  3. Config changes — Full invalidation triggered
  4. Plugin version changes — MDX cache invalidated

Manual InvalidationLink

Delete the cache directory:

rm -rf .boltdocs

Or in development, the dev server auto-invalidates on file changes.


Cache LocationLink

By default, cache lives in .boltdocs/ at your project root:

my-docs/
├── .boltdocs/
│   ├── build/
│   │   ├── framework-hash.txt
│   │   ├── template-index.html
│   │   ├── render-cache.json
│   │   └── pages/         ← Per-page cached HTML
│   ├── cache/
│   │   ├── parser/        ← Parser results (JSON)
│   │   ├── mdx/           ← MDX compiled code
│   │   ├── routes/        ← Route metadata
│   │   └── assets/        ← Processed assets
│   ├── generated/
│   │   ├── types.d.ts
│   │   └── link-tree.json
│   ├── reports/
│   │   ├── doctor.json
│   │   └── performance.json
│   └── backups/           ← Doctor fix backups
├── docs/
└── boltdocs.config.ts

TroubleshootingLink

Cache corruptionLink

If you suspect corrupted cache entries:

# Clear all caches
rm -rf .boltdocs

# Restart dev server
pnpm docs:dev

Stale content in productionLink

Ensure your CI pipeline starts fresh:

# Clean before build
rm -rf .boltdocs
pnpm docs:build

Large cache sizeLink

For very large documentation sites:

# Disable compression to save CPU at the cost of disk space
BOLTDOCS_CACHE_COMPRESS=0 pnpm docs:build

Performance NotesLink

  • First startup is slower — cache is being populated
  • Subsequent startups are near-instant (< 100ms)
  • The more pages you have, the more cache helps
  • Cache compression adds ~10% CPU overhead but saves ~70% disk
Last updated on July 27, 2026

Was this page helpful?