Keep per-build values out of the Nuxt build cache key
nuxt/config/no-per-build-value-in-cache-keysrc/rule-packs/nuxt/rules/nuxt/no-per-build-value-in-cache-key.ts Upstream docs Run this rule
pnpm nuxt doctor --rules nuxt/config/no-per-build-value-in-cache-key
Why it matters
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.
Recommended 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.
Useful links
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