{"record":{"id":"a426b19128a39ad1","repo":"withastro/astro","slug":"skipping-cache-for-url-pathname-url-search-be","errorCode":null,"errorMessage":"Skipping cache for ${url.pathname}${url.search} because response includes Set-Cookie.","messagePattern":"Skipping cache for (.+?)(.+?) because response includes Set-Cookie\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/cache/memory-provider.ts","lineNumber":276,"sourceCode":"\tif (!entry.vary || !entry.varyValues) return true;\n\tfor (const header of entry.vary) {\n\t\tconst requestValue = request.headers.get(header) ?? '';\n\t\tif (requestValue !== entry.varyValues[header]) return false;\n\t}\n\treturn true;\n}\n\nfunction hasAtLeastOneCookie(cookies: AstroCookies | undefined): boolean {\n\treturn cookies ? !cookies.headers().next().done : false;\n}\n\nfunction hasSetCookieHeader(response: Response): boolean {\n\tif (response.headers.has('set-cookie')) return true;\n\treturn hasAtLeastOneCookie(getCookiesFromResponse(response));\n}\n\nfunction warnSkippedSetCookie(logger: AstroRuntimeLogger, url: URL): void {\n\tlogger.warn(\n\t\t`Skipping cache for ${url.pathname}${url.search} because response includes Set-Cookie.`,\n\t);\n}\n\nfunction warnSkippedVary(logger: AstroRuntimeLogger, url: URL, header: 'Cookie' | '*'): void {\n\tlogger.warn(\n\t\t`Skipping cache for ${url.pathname}${url.search} because response includes Vary: ${header}.`,\n\t);\n}\n\n/**\n * Simple LRU cache backed by a Map (insertion-order iteration).\n * When the cache exceeds `max` entries, the oldest entry is evicted.\n */\nclass LRUMap<K, V> {\n\t#map = new Map<K, V>();\n\t#max: number;\n","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/core/cache/memory-provider.ts#L258-L294","documentation":"During cached-route handling in the Astro experimental route cache memory provider, a response was about to be stored, but hasSetCookieHeader() detected either a literal Set-Cookie header on the Response or at least one cookie appended via Astro's cookies API (AstroCookies). Responses that set cookies are considered user-specific, so caching them would leak per-user data to other visitors; the provider skips caching this URL and logs this warning.","triggerScenarios":"Thrown at packages/astro/src/core/cache/memory-provider.ts:276 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove cookies.set(...) / response Set-Cookie headers from responses you want cached","Move personalized logic that sets cookies into middleware or an API route excluded from caching","If the cookie is session-related, ensure the cached route does not depend on session state"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e294953aa8aadd98d5be92e60a03037b05dbdfd4","analyzedAt":"2026-09-09T03:35:40.650Z","contentChangedAt":"2026-09-09T03:35:40.650Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}