News Infrastructure

Vercel CDN Stops Caching Responses That Vary by Cookie

Vercel CDN no longer stores origin responses whose Vary header includes Cookie, and affected responses show a MISS status in the x-vercel-cache header.

Vercel CDN no longer caches origin responses when their Vary header includes Cookie, so those responses are served but not stored for later visitors. Vercel says the Vary header tells a cache which request headers can change a response.

Vercel says cookies often hold visitor-specific values. Varying by Cookie can therefore create many cache entries that are rarely reused. The response still reaches the visitor normally, but the CDN does not keep a copy for future requests.

Affected responses can be spotted in two places. The x-vercel-cache header is set to MISS, and Runtime Logs list vary_key_denied:cookie as the cache reason.

If a route expected to be cached shows that reason, Vercel points to the Vary header returned by the origin. When the response is the same regardless of cookies, removing Cookie from Vary lets the CDN cache it, provided it meets the other caching requirements. When the response depends on cookies, Cookie stays in Vary, and Cache-Control: private keeps personalized responses out of the shared CDN cache. Caching for other supported Vary headers is unchanged.

Source: Vercel CDN no longer caches responses with Vary: Cookie – Vercel.