next.jsvercel

Vercel serving stale version of static files, after rebuild


I have come across a seemingly significant issue with the Vercel cache.

Background

Problem


SCREEN SHOTS

Build output:

enter image description here

HTTP Request and Response, on first page visit after redeploying:

enter image description here

enter image description here

HTTP Request and Response on subsequent visits to the site:

enter image description here

enter image description here


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:


Solution

  • 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 next@13.3.0 --save

    Release link: https://github.com/vercel/next.js/releases/tag/v13.3.0