withastro/astro · error
Skipping cache for ${url.pathname}${url.search} because resp
Error message
Skipping cache for ${url.pathname}${url.search} because response includes Set-Cookie. What it means
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.
Source
Thrown at packages/astro/src/core/cache/memory-provider.ts:276
if (!entry.vary || !entry.varyValues) return true;
for (const header of entry.vary) {
const requestValue = request.headers.get(header) ?? '';
if (requestValue !== entry.varyValues[header]) return false;
}
return true;
}
function hasAtLeastOneCookie(cookies: AstroCookies | undefined): boolean {
return cookies ? !cookies.headers().next().done : false;
}
function hasSetCookieHeader(response: Response): boolean {
if (response.headers.has('set-cookie')) return true;
return hasAtLeastOneCookie(getCookiesFromResponse(response));
}
function warnSkippedSetCookie(logger: AstroRuntimeLogger, url: URL): void {
logger.warn(
`Skipping cache for ${url.pathname}${url.search} because response includes Set-Cookie.`,
);
}
function warnSkippedVary(logger: AstroRuntimeLogger, url: URL, header: 'Cookie' | '*'): void {
logger.warn(
`Skipping cache for ${url.pathname}${url.search} because response includes Vary: ${header}.`,
);
}
/**
* Simple LRU cache backed by a Map (insertion-order iteration).
* When the cache exceeds `max` entries, the oldest entry is evicted.
*/
class LRUMap<K, V> {
#map = new Map<K, V>();
#max: number;
View on GitHub (pinned to e294953aa8)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/astro/src/core/cache/memory-provider.ts:276 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of withastro/astro@e294953aa8 (2026-09-09).
Data as JSON: /api/errors/a426b19128a39ad1.
Report an issue: GitHub.