Next.js Discord

Discord Forum

Next fetch-cache not invalidated during build

Unanswered
American black bear posted this in #help-forum
Open in Discord
Avatar
American black bearOP
In my .next/cache/fetch-cache directory, I have fetches that are being cached during build of static pages. These are supposed to be cached for 60 seconds only, as you can see in the cached file here:

{"kind":"FETCH","data":{"headers":{"apigw-requestid":"C9-K6gpfoAMEM4g=","connection":"keep-alive","content-length":"6315","content-type":"application/json","date":"Wed, 18 Dec 2024 03:39:11 GMT"},"body":"<...data...>","status":200,"url":"https://website.com/get-image/71a797d3-37ba-431b-bbc4-bd65f8daefa9"},"revalidate":60,"tags":[]}


However, it seems that the date only gets updated "sometimes" while the data "never" does. I always have to either:

1. Delete the cached file before next build
or
2. Run an action after deployment that calls revalidatePath()
or
3. Wait for the revalidate time after deployment where it properly goes stale and revalidates

I would expect that as soon as the date plus the revalidate are less than the current datetime, that it would revalidate during the build - but it never does for me, only after deployment.

I read the documentation carefully and everything seems to say that Next doesn't cache by default while mine is definitely being cached and not revalidating during build.

0 Replies