{"record":{"id":"e69974d6898b5643","repo":"withastro/astro","slug":"skipping-cache-for-url-pathname-url-search-be-e69974","errorCode":null,"errorMessage":"Skipping cache for ${url.pathname}${url.search} because response includes Vary: ${header}.","messagePattern":"Skipping cache for (.+?)(.+?) because response includes Vary: (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/astro/src/core/cache/memory-provider.ts","lineNumber":282,"sourceCode":"}\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\n\tconstructor(max: number) {\n\t\tthis.#max = max;\n\t}\n\n\tget(key: K): V | undefined {\n\t\tconst value = this.#map.get(key);","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/withastro/astro/blob/e294953aa8aadd98d5be92e60a03037b05dbdfd4/packages/astro/src/core/cache/memory-provider.ts#L264-L300","documentation":"Before serving or storing a cached response, the memory cache provider checks the response's Vary header. When Vary names 'Cookie' or '*' the response cannot be safely reused across requests, because its content depends on request cookies (or, with '*', on arbitrary request headers) that the cache does not differentiate on. warnSkippedVary reports that this URL is skipped from caching for that reason.","triggerScenarios":"Thrown at packages/astro/src/core/cache/memory-provider.ts:282 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the 'Vary: Cookie' (or 'Vary: *') header from the response so it can be cached","Serve cookie-dependent variants from an uncached API route or middleware instead","Restrict cookie-dependent rendering to routes excluded from cache caching"],"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"}