Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

Troubleshooting changes not reflecting in live website for Next JS + Sanity project

13 replies
Last updated: Jun 14, 2023
Hello. I have a Next JS + Sanity project. Some thank you/error messages also come from Sanity in this project. But there is one problem. Although I change the information in Sanity, the changes only take effect locally. This is the case even though there is dataset production. On the live website, the changes are not visible. What could be the reason for this and how do I solve it?
"
https://www.sanity.io/answers/changes-made-in-my-production-studio-arent-affecting-my-website " The link here mentions editing the revalidate values.
"`export async function getStaticProps({ preview = false }) {`

const data = await getClient().fetch(query);


return {

props: { preview, data },

revalidate: 10,

};

}

`export default HomePage;`"

But as you can see in these codes, it is already set to a very short time in the project. Why aren't the changes visible on the live site though?
Jun 11, 2023, 3:22 PM
Hello, Nice to meet you. I am very interest in your project
Jun 11, 2023, 3:25 PM
Hello. Thanks for your interest. But this project is my client's project. Unfortunately, I couldn't figure out the cause of the problem. Do you have an idea?
Jun 11, 2023, 3:28 PM
Do you have useCdn as true in your sanity client config?
Jun 11, 2023, 3:52 PM
user L
Hello. Thanks for your response. The value of useCdn in the project is false.
Jun 11, 2023, 4:01 PM
If you open your Network tab, select the request for your home page, and then view the response headers, are you seeing a hit against the Vercel cache? What if you refresh after 10 seconds, and then again after another 10 seconds? If you don’t ever see STALE, I’m not sure Next.js will revalidate. If you do see STALE, wait another 15 seconds and refresh. If it’s still the old data, then presumably the Next.js validation is working and the data being sourced is stale.
Jun 11, 2023, 4:53 PM
user A
Hello. Thank you for your response. I think these should be the values you are talking about.
1.
age: 862.
cache-control: public, max-age=0, must-revalidate3.
content-encoding: br4.
content-type: text/html; charset=utf-85.
date: Sun, 11 Jun 2023 17:22:16 GMT6.
etag: "myetag"7.
server: Netlify8.
strict-transport-security: max-age=31536000; includeSubDomains; preload9.
vary: Accept-Encoding10.
x-nextjs-cache: STALE11.
x-nf-render-mode: odb ttl=6012.
x-nf-request-id: 01H2NQNQ6N59FJ6ZSYV51YXD0Y13.
x-powered-by: Next.jsAnd when you refresh it again after 15 seconds, the results are as follows.

1.
age: 18482.
cache-control: public, max-age=0, must-revalidate3.
content-encoding: br4.
content-type: text/html; charset=utf-85.
date: Sun, 11 Jun 2023 17:53:03 GMT6.
etag: "myetag"7.
server: Netlify8.
strict-transport-security: max-age=31536000; includeSubDomains; preload9.
vary: Accept-Encoding10.
x-nextjs-cache: STALE11.
x-nf-render-mode: odb ttl=6012.
x-nf-request-id: 01H2NSE2ZHQ0AYAJPND0T5DEKE13.
x-powered-by: Next.js
Jun 11, 2023, 5:56 PM
I haven’t tried using ISR on Netlify, but have you confirmed you’ve followed their configuration steps ?
Jun 11, 2023, 6:37 PM
user A
Hello again. As far as I can see in my experiment, these changes are only valid in Vercel. Changes are not visible in Netlify without redeploying. Even though I made the changes in the ISR document, the result is the same. Of course if I did it right. The changes I made are as follows:"`[[redirects]]`

from = "/studio/*"

to = "/studio/index.html"

status = 200

force = false

[functions]
`included_files = ["studio/**"]`".
(I added the Functions part.)

My client uses Netlify. Do you think there is a way I can solve this?
Jun 11, 2023, 7:49 PM
Your content won’t be stored in the
studio
directory (I assume that’s where your Sanity Studio files are), so I don’t believe this is where you want to point
included_files
at. You might instead want to use the
.next
directory or something similar.
Jun 11, 2023, 8:17 PM
Do you think there is a way I can solve this?
I hope so. Even if you don’t use ISR, there are alternatives like running a build when content updates. This can be automated by using webhooks .
Jun 11, 2023, 8:18 PM
user A
Thanks. Netlify now automatically redeploys when data is updated. This solved my problem in the short term.
But in the long run, I guess there should be a way to do this with ISR. In Vercel I can do this without redeploying, constantly deploying in Netlify will cause it to waste build minutes. Do you think there is a way to solve this?
Jun 13, 2023, 2:44 PM
I’m glad to hear it! 🎉
I’m not sure how well ISR works with Netlify nor what their plans are going forward. ISR changes with the new Apps Router in Next.js, but it would be up to Netlify whether to support that. Getting ISR working on Netlify may be best asked in their community support forum, though others here are of course welcome to chime in if they have input.
😀
Jun 13, 2023, 2:50 PM
user A
I got it. Thank you very much again. 🙂
Jun 14, 2023, 2:03 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?