Understanding the timing of changes in the Sanity studio and their reflection on the front end.
6 replies
Last updated: Apr 7, 2022
S
When an editor makes a change in the Sanity studio, how long until those changes will be reflected on the front end usually? hosted with vercel
Apr 6, 2022, 3:25 AM
Hi User - it depends entirely on how your front end is built. For example, it might be built in such a way that whenever a user visits the page, the page goes to fetch the latest data from Sanity. In that case, it would update as soon as a user refreshes the page. Or, even more speedy, it might be built to subscribe to changes in Sanity so that it updates automatically without a page reload --- that would be one extreme that would prioritize fresh data (and be potentially very expensive in terms of API requests).
On the other extreme is where it is set up to rebuild the site statically whenever it is told to - either by a deploy button in your studio and/or some other means (like pushing code to a repo, or clicking something like "deploy" or "build" in Vercel somewhere). In that case, the front end only ever goes to fetch data from Sanity and update itself when it is "told" to by someone with access to the studio and/or Vercel and/or code repo. The benefit of that scenario is your pages are pre-built and thus load very fast, and you are not paying for API calls every time someone lands on a page. You can even set things up so some parts of your site are dynamic and others are statically built --- so basically it all just depends! What is your front end built with?
On the other extreme is where it is set up to rebuild the site statically whenever it is told to - either by a deploy button in your studio and/or some other means (like pushing code to a repo, or clicking something like "deploy" or "build" in Vercel somewhere). In that case, the front end only ever goes to fetch data from Sanity and update itself when it is "told" to by someone with access to the studio and/or Vercel and/or code repo. The benefit of that scenario is your pages are pre-built and thus load very fast, and you are not paying for API calls every time someone lands on a page. You can even set things up so some parts of your site are dynamic and others are statically built --- so basically it all just depends! What is your front end built with?
Apr 6, 2022, 11:22 AM
J
Great answer User. The content is available effectively right away (lag and a bit of processing speed can take a moment at times depending on your fe server and isp). The other thing to consider is if you’re using the CDN feature. It’s an ‘edge cache’ that has cheaper and faster queries but as it’s a cache of the content can be a bit slower to load new updates.
Apr 6, 2022, 6:18 PM
J
It’s fast enough to use as a decent chat storage, though I wouldn’t advise this as a use case for sanity or similar typical content delivery solutions as they aren’t really optimized for that. But if you wanted to make some chat or almost real time functions you could.
Apr 6, 2022, 6:21 PM
S
Hey, great answers thanks so much for taking the time! My front end is built with Next - I like the sound of the latter option via a deploy button
Apr 6, 2022, 11:36 PM
Seems like this plugin by
user J
might do the trick. https://www.sanity.io/plugins/vercel-deploy Apr 7, 2022, 11:15 AM
S
🙏
Apr 7, 2022, 2:39 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.