sanity-io / template-nextjs-personal-website

A Next.js Personal Website with a Native Authoring Experience
https://template-nextjs-personal-website.sanity.build
221 stars 49 forks source link

RevalidateTag fails randomly on production #199

Open valse opened 4 months ago

valse commented 4 months ago

Hi, I'm facing same issues with the current revalidate setting on the loadQuery method because on production in a Vercel web app, revalidating by the webhook not all the pages with the desired tag are refreshed correctly.

Disabling the cache on the loadQuery revalidate property all works as expected.

Why you've chosen to enable the cache in this scenario?

Thanks!

stipsan commented 4 months ago

Can you elaborate what you mean by works correctly? If you refresh multiple times after the revalidateTag call is made does it eventually show the new content? Or is it "stuck" forever on some pages no matter what you do?

valse commented 4 months ago

Hi, exactly the second one: if you have for example 2 pages with the same tag sometimes the revalidate purge both, sometimes only one or none of them. Keeping the revalidate like this:

let revalidate: NextFetchRequestConfig['revalidate'] = 0

It works as expected refreshing always all the contents.

valse commented 4 months ago

I just realized that disabling the cache setting the revalidate to 0 is like having a dynamic page that queries sanity for each requests 🤦🏼‍♂️

I saw that it's a bug using the generateStaticParams feature: avoiding it but using the cache, setting the revalidate properties to false, the page caches the calls to sanity until the next revalidateTag request.

nikolailehbrink commented 2 months ago

Hi @valse, I have exactly the same problem that when I update a project from the starter template, the preview for the project on the home page is revalidated but not the individual project page. This is related to the problem you linked and the only thing to do is to wait until the next team has found a solution, correct?

valse commented 2 months ago

Hi @nikolailehbrink... yes for the moment the problem still exists but I found a workaround that not prerender the pages on build but it cache the requests and revalidate them.

nikolailehbrink commented 2 months ago

Oh wow! 😄 Okay, I will look into it! Thank you @valse!