Replies: 3 comments
-
this seems to be related to https://github.com/orgs/vercel/discussions/3259 and https://github.com/orgs/vercel/discussions/3980 but none of those seem to have any resolutions yet |
Beta Was this translation helpful? Give feedback.
-
While I'm still having difficulties getting the cache to hit or miss appropriately according to the specified |
Beta Was this translation helpful? Give feedback.
-
I too am having this problem. |
Beta Was this translation helpful? Give feedback.
-
Summary
I have a Vercel Serverless function at a GET endpoint that fetches a value from KV and then returns its contents.
This works perfectly fine in local dev. It also works exactly once after deploying it to Vercel, but then after that initial success, every subsequent call to this endpoint returns the same stale data it fetched the first time, even if the data has since updated.
Thinking this may be some cache issue, I added some cache headers:
This did nothing. In fact, inspecting the response headers in Postman, I can see the Cache-Control and Cdn-Cache-Control are both set as I wrote them, but the Age field will happily tick up into multiple minutes worth of stale data.
What gives? I have another endpoint which does basically the same thing except it also checks an auth token in the header, and it works perfectly fine. Why does this response get so stale, and only when deployed to Vercel? Is there some magic button somewhere I forgot to press?
Example
https://transit-trek.vercel.app/api/public-get
Steps to Reproduce
Go to
https://transit-trek.vercel.app/api/public-get
See that the
Age
header is allowed to reach multiple minutes old, and thatX-Vercel-Cache
is alwaysHIT
. This is despite the code above with the specified cache headers. Removing all cache headers results in the same behavior.Beta Was this translation helpful? Give feedback.
All reactions