Keep per-request state out of pages served from a shared cache
nuxt/ssr/no-request-state-in-cached-pagesrc/rule-packs/nuxt/rules/nuxt/no-request-state-in-cached-page.ts Upstream docs Run this rule
pnpm nuxt doctor --rules nuxt/ssr/no-request-state-in-cached-page
Why it matters
Nitro merges matching route rules most specific first. A cached handler receives only the request headers listed in cache.varies but retains the original event.context. Doctor checks the resolved rules in a current Nuxt manifest, including inline defineRouteRules and nitro.routeRules. It skips client-only reads and routes that bypass SSR through a redirect, proxy, or ssr: false. For cache and swr, a read is covered only when all its known headers are listed in cache.varies; varying on headers does not prove coverage for event.context. URL queries are part of Nitro's runtime cache key, but static prerendered files do not vary by query. Doctor reports ISR only for verified production preset and route combinations, and records evidence gaps for unproven cache coverage, such as dynamic page routes or stale page inputs.
Recommended fix
Move the per-visitor part to the client (onMounted(), import.meta.client, or <ClientOnly>) or to an uncached API call, or exclude the route from the cache with cache: false, isr: false, or prerender: false. For a cache keyed on a header, list it in cache.varies.
Useful links
Example
Read the session on the client of a cached page
Before
<!-- routeRules: { '/pricing': { swr: 3600 } } -->
<script setup lang="ts">
const headers = useRequestHeaders(['cookie'])
const { data: plan } = await useFetch('/api/me/plan', { headers })
</script>
After
<!-- routeRules: { '/pricing': { swr: 3600 } } -->
<script setup lang="ts">
const { data: plan } = useFetch('/api/me/plan', { server: false })
</script>