#Vercel Cache

1 messages · Page 1 of 1 (latest)

eager nest
#

Does Vercel Cache works on 301 redirect responses returned from Edge Middleware?
My 301 responses have cache-control set to public with s-maxage of 86400.

sudden warrenBOT
#

Hi @eager nest. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, Vercel's Edge Network does cache 301 redirect responses returned from Edge Middleware. According to the Vercel documentation (https://vercel.com/docs/edge-network/caching), for server responses to be successfully cached with Vercel's Edge Network, the response must use a 200, 404, 301, or 308 status code.

However, there are several other criteria that must also be met for a response to be cacheable:

  • The request uses the GET or HEAD method.
  • The request does not contain a Range or Authorization header.
  • The response does not exceed 10MB in content length.
  • The response does not contain the set-cookie header.
  • The response does not contain the private, no-cache or no-store directives in the Cache-Control header.

As long as your 301 responses meet these criteria and have a Cache-Control header set to public with s-maxage=86400, they should be cached by Vercel's Edge Network.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@eager nest kapa.ai is still learning and improving, please let us know how it did by reacting below