Next.js Discord

Discord Forum

I fetch from CMS but if it is offline I don't want to throw error...

Answered
Rhinelander posted this in #help-forum
Open in Discord
RhinelanderOP
I fetch from CMS get the data... All good but what if my CMS is offline I would like to cache latest data that my app got from there. If is set revalidate to something like 900 it will keep that just from 15 minutes and after that show error screen. Since this is a blog and new things gets added all the time data needs to be fresh. What should I do
Answered by B33fb0n3
Then you might want to cache the page for an infinite amount of time. When the cms is offline, there shouldn't be updates to the content. So that's fine. If the cms is online again and something changes, you can revalidate the page and the page instantly gets the new details
View full answer

8 Replies

RhinelanderOP
I dont want user to see that cms is offline. Solution above is already implemented. Sure message in the logs but i dont want user to know that, i just want them to use app like there is no problem
@Rhinelander I dont want user to see that cms is offline. Solution above is already implemented. Sure message in the logs but i dont want user to know that, i just want them to use app like there is no problem
... and after that show error screen
but that does not sound like that your user shouldn't know that there is an error 🤔
Can you clarify that please?
RhinelanderOP
Well i want user to access the cached blog all the time. Not to throw error if there is problem with my cms. If there is problem with cms i will try to fix that but i dont want user to see that there is problem
@Rhinelander Well i want user to access the cached blog all the time. Not to throw error if there is problem with my cms. If there is problem with cms i will try to fix that but i dont want user to see that there is problem
Then you might want to cache the page for an infinite amount of time. When the cms is offline, there shouldn't be updates to the content. So that's fine. If the cms is online again and something changes, you can revalidate the page and the page instantly gets the new details
Answer
RhinelanderOP
Thanks
Happy to help