I have come across a seemingly significant issue with the Vercel cache.
Background
Problem
SCREEN SHOTS
Build output:
HTTP Request and Response, on first page visit after redeploying:
HTTP Request and Response on subsequent visits to the site:
Observations and Question
As seen from the x-vercel-cache
header, Vercel does indeed grab the new (non-stale) files from the static build when a client first visits the page after redeploying (definition of PRERENDER here).
On subsequent visits, however, it shows stale / old data. That data was served from the Vercel cache (HIT in the x-vercel-cache
header). For some bizarre reason, it does not look like the Vercel cache was updated with the latest files from the static build, during the first visit.
Any idea what is going on here, and how to fix it?
Edit:
I have made a few findings, these are as follows:
.next/cache
on build, we are certain that the fetches running build-time do not get old data from .next/cache
revalidate: X
to the fetch, because in the latter alternative the first fetch in the app will always get stale data from the cachenext build
+ next start
locallyx-vercel-cache
, but old stale data is servedx-vercel-cache
header)This seems to be an issue with certain versions of Next 13 while deployed on Vercel. In my case, I was running v13.2.4
.
Next has just released v13.3.0
which seems to have resolved this caching issue.
Updated using npm:
npm install [email protected] --save
Release link: https://github.com/vercel/next.js/releases/tag/v13.3.0