Next.js Discord

Discord Forum

Can't get rid of old build cache

Unanswered
Penta posted this in #help-forum
Open in Discord
I can not for the life of me get rid of the old build cache on my nextjs app.

My index page is loading old css and html, and the components it imports also use the old outdated builds.
Certain pages update fine. I DONT GET IT
I have read everything available. I've tried making every page dynamic, I've tried forcing it using the export const dynamic, I've tried deleting the .next folder that contains the cache, WHILE ON PRODUCTION, forced and rebuilt, deployed,

same thing.

I am hosting on digital ocean and the preview link they give me works fine, however on the domain it's not the same case.

Please, help. Would appreciate any.
Thanks.

26 Replies

?! please
it also keeps serving old files
Have you set up any custom generate build id? If not this might be why. It is sort of what is part of the cache and what is not
Original message was deleted
yes trust me this is a cache problem on nextjs side or some weird digitalocean cdn bug
this never happend before it just popped up out of nowhere
now heres some additional context: if i access domain.com, the homepage serves the old build cache. if i navigate to for example domain.com/search, it retrieves the new ssgmanifest and such and if i click the route that sends me to "/" it magically renders the NEW build
its so weird it makes no sense
@Penta yes i did set that up
So. The generate build id is used with the caching key, so that might be part of this issue
@MikeTheTechLead So. The generate build id is used with the caching key, so that might be part of this issue
yes but i set that up as part of a solution because i read that would solve my errors
any idea anyone?
Just guessing here, maybe you have your domain registered with Cloudflare and have their cache system enabled?
@D Trombett Just guessing here, maybe you have your domain registered with Cloudflare and have their cache system enabled?
thats a great guess
i registered it for an hour before getting rid of cloudflare from my website. but that was ~2 weeks ago. do you think even after removing it, it still affects with the cache?
If you're domain is not proxied anymore through Cloudflare, then no, the only cache available should be the one of your server and of the browser
This issue is out of this world honestly. I feel so stuck nothing makes sense
I honestly don't know, if you've tried deleting the .next folder and restarted the website than the cache can only be present in the browser
Or maybe is served by your server/proxy
@D Trombett But the build is fine, the digital ocean preview app works fine, only in the domain.com the problem occurs. I can't think of a root cause, the digital ocean support system is scandalous. Seems like I either have to completely drop nextjs to evade this cache problem, or change webhost
You could try inspecting a bit the headers of the request in your browser
@D Trombett Hey, I discovered that even thought i had removed cloudflare, it was still serving the same cache. I tried purging the cache from CF and it was okay for 2 minutes until it loaded the same old cache and now its still impossible to retrieve it.
Do you think the nextjs cache and cf cache clash with each other and its impossible to serve the new build?
Mmh, I would entirely disable cloudflare caching in this case
All of their cache options
@D Trombett All of their cache options
sadly I did and it persists. purged multiple times
I'm sorry but I really don't know what's going on then
I recently deployed a next.js website in a cloudflare domain with the cache options enabled and it updated without any problems