NUXT0091Keep per-build values out of the Nuxt build cache key
Why it happens
experimental.buildCache restores the client and server bundles when nothing that feeds the build changed. Its key hashes each local layer's raw nuxt.config, so appConfig, app.head, vite.define, routeRules and module options are all part of it. A value computed when the config loads gives every build a new key, and the cache never hits. Nuxt removes only buildId, serverDir, nitro, devServer, runtimeConfig, logLevel, devServerHandlers and devtools from the hashed config, and only at the top level: $production.runtimeConfig is still hashed. Functions are hashed by their source text, so a value computed inside a hook or plugin body does not change the key. Doctor reports only when the resolved config (or a literal experimental.buildCache: true) shows the cache is on.
Fix
Move the value to the top-level runtimeConfig, runtimeConfig.public for client code, and read it with useRuntimeConfig(). Nitro is always rebuilt, so the value stays current on every build.
Example
Keep the build time in runtime config
Before
export default defineNuxtConfig({
experimental: { buildCache: true },
appConfig: { buildTime: new Date().toISOString() },
})
After
export default defineNuxtConfig({
experimental: { buildCache: true },
runtimeConfig: { public: { buildTime: new Date().toISOString() } },
})
// app/pages/index.vue
const { buildTime } = useRuntimeConfig().public
Verify the fix
Run only this rule after editing so the report stays focused on the diagnostic you are closing:
pnpm nuxt doctor --rules nuxt/config/no-per-build-value-in-cache-key