Skip to content

Fix: Include themeVariables in preview cache key#205

Merged
taylortom merged 1 commit into
masterfrom
fix/preview-cache-themevars
May 29, 2026
Merged

Fix: Include themeVariables in preview cache key#205
taylortom merged 1 commit into
masterfrom
fix/preview-cache-themevars

Conversation

@taylortom
Copy link
Copy Markdown
Contributor

Fixes #204

Fix

  • Add a varsHash component to the preview prebuilt cache key — a deterministic 12-char hash over themeVariables and customStyle — so two courses sharing the same (pluginHash, theme, menu) but with different presets or custom LESS no longer collide on the cache.
  • Hash the raw mongo course.data before preBuildHook/applySchemaDefaults mutate it, so the same course consistently produces the same hash across runs. This also matches the eager prebuild's "no customisation" view, so default-themed real courses correctly share its cache entry.
  • Extend BuildCache.{getPath,has,populate,restore} to take and append the varsHash to the cache directory name.
  • Update prebuildCache to populate with the hash of empty inputs (DEFAULT_VARS_HASH).

Testing

  • node --experimental-test-module-mocks --test 'tests/**/*.spec.js' passes (28 tests, including new utils-computeVarsHash.spec.js and extended BuildCache.spec.js).
  • npx standard is clean.
  • Manual: preview course A with default preset, then preview course B (same plugins/theme/menu) with a changed preset colour — course B's CSS now reflects its own preset, not course A's.
  • Manual: re-preview course A — still served from the original (default-vars) cache entry, no rebuild.

@taylortom taylortom force-pushed the fix/preview-cache-themevars branch from 01afaf0 to 091c4ad Compare May 29, 2026 10:35
@taylortom taylortom merged commit 4358038 into master May 29, 2026
2 checks passed
@taylortom taylortom deleted the fix/preview-cache-themevars branch May 29, 2026 10:43
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 3.1.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview prebuilt cache masks per-course theme customisations

1 participant