BlogRevalidating the NextJS cache
I've been making NextJS apps for two years now and the number one complaint I see is about the cache. Although I understand how it can be confusing at times, the team at vercel has gone at length in trying to explain how it works.
The below link features Lee Robinson, VP of product at Vercel, walking through how the NextJS cache works.
https://www.youtube.com/watch?v=VBlSe8tvg4U&ab_channel=Vercel
A challenge that I just faced with my site was that my get calls were being cached permanently, only another deployment would wipe them out. While I'd rather this than the site hitting the CMS (Sanity) api every page load, it was still unacceptable for when I create / update my content.
Victor Eke has a great solution written for my exact problem with his blog post here.
https://victoreke.com/blog/sanity-webhooks-and-on-demand-revalidation-in-nextjs
I was able to implement Victors implementation in about 30 minutes and now I have a platform that is cached 99.9% of the time, but revalidates when changes are made in the CMS.
This exercise helped me better understand caching in NextJS. From what I understand this feature will be opt in when version 15 is ready. While I understand developer gripes with the NextJS caching feature, I'd rather be over cached than under cached.