-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content not updating when making changes in Sanity studio #3
Comments
Hey, @anthonyiu. Are you publishing the document after you make a change? Because the deploy hooks are only triggered after the document has been published. If you're publishing the document and still not getting any deployment hooks triggered, I'll suggest you take a closer look at the URL endpoint you copied from Vercel to make sure they match with the one on Sanity. Also check if the |
Hi Victor, the hook was triggered after I published through the sanity studio (as confirmed by Vercel deployment log, which stated that the update was made by Deploy Hook). However, it just didn't show the changes on any of the page, no matter I updated job, project or any data. Any clue? |
I somehow missed the screenshot you added to your earlier response. Sorry about that. If the hooks are being triggered as expected, I'm not entirely sure what the issue might be, and it's harder to troubleshoot the problem without any code examples. A few suggestions I can recommend are:
|
Hi Victor,
! found that the studio is "Not deployed" when I logged in via https://www.sanity.io/manage. I googled it and followed the steps here at https://www.sanity.io/plugins/vercel-deploy to install the plugin to deploy on Vercel. It didn't work too. Maybe I will redo this project once again to see what's missing~ sigh... |
It's optional to deploy the studio on Sanity, so not really the issue in case. As for the deployment issues, sorry I can't provide a solution. Maybe you'll have better luck this time. |
Hi Victor, finally I have resolved this after getting stuck for days. Simply add |
I believe the issue is due to Next's native fetch caching It is indeed the fetch that is returning stale data with an outdated |
Theoretically, we should be able to bypass the fetch caching by placing this in the export const dynamic = 'force-dynamic' But the behavior in that case is that the first page load contains stale data, and after a refresh it is updated. This even occurs with statically built pages. Adding this to the export const revalidate = 10; |
While this will work, it may not be a really good solution as it greatly increases the request cost on Sanity. This was why I expressly choose the hooks way. If you want to keep using revalidation, I highly suggest you use on-demand revalidation instead as data revalidation happens only when the data changes (on demand), and not on a fixed time frame of say 10secs. This is infact recommended by leerob. You can check out this issue to learn how it is setup and check out a live example usage here |
Why not just go full-on on-demand revalidation? |
I agree that rebuilding the site with webhooks is the best way to accomplish this. However it appears there is a bug in the implementation somewhere. I'm seeing the same behavior that @anthonyiu mentioned in his first message. After some more research, it looks like this is a known problem with Sanity's slack community suggests using |
Cool. Let me know the outcome when you do. |
Hi all, I also did some research in Sanity and Vercel. I tried the revaldiateTag(). It works for me but ONLY when single tag is used and after I clicked "Purge Everything" in Data Cache in my project setting in Vercel. This issue has been raised to both Sanity and Vercel, Sanity said it seems to be an issue from Vercel. For more information, please see below. |
Hey all. So I wrote an article on how to set-up on-demand revalidation to get content updates both in production and development. Do give it a read if you like: https://victoreke.com/blog/sanity-webhooks-and-on-demand-revalidation-in-nextjs Within the week, I'll integrate it into this site as well. Until then, happy coding! |
Hi Victor and all,
I've been following this tutorial and it's amazing to learn about Sanity headless CMS.
However, I encountered an issue about using the studio. Whenever I make changes in the studio, it does not reflect the changes on the website. I did set up the deployment hook to make sure that the site rebuilds automatically every time I save changes in the studio. Does anyone know why? Should I use getStaticProps() to fetch the data instead? Here is a deployment log from Vercel for your information. Thank you.
The text was updated successfully, but these errors were encountered: