Update client side when user update items
Unanswered
! VINKE posted this in #help-forum
! VINKEOP
I'm creating a platform to manage stock for resellers, for now, when the user modifies an item in stock, I do a router.refresh() to update the data and keep it up to date on the client side , but imagine if 1000 people update the article at the same time, maybe the server will be down?
So I want to know what is the best practice for this, i mind about caching but I can't really figure out how I can use it.
Thank for your response
So I want to know what is the best practice for this, i mind about caching but I can't really figure out how I can use it.
Thank for your response
5 Replies
Belgian Hare
@! VINKE You can see cache documentation using "use cache" here.
https://nextjs.org/docs/canary/app/api-reference/directives/use-cache
What you're talking about though is "1000 people updating the article at the same time", "use-cache" on the component/function/file wont help here as it's a bottleneck on update speed not on speed to get the data.
I would in the first place why 1000 people are updating the same article / second this seems outrageous, then I would say this as an issue ethier fixed by a rate-limit to prevent updating articles more than say 60x/second or use a data storage system where updating 1000/s is not an issue like (point-read / point-write) data stores like dynamo
https://nextjs.org/docs/canary/app/api-reference/directives/use-cache
What you're talking about though is "1000 people updating the article at the same time", "use-cache" on the component/function/file wont help here as it's a bottleneck on update speed not on speed to get the data.
I would in the first place why 1000 people are updating the same article / second this seems outrageous, then I would say this as an issue ethier fixed by a rate-limit to prevent updating articles more than say 60x/second or use a data storage system where updating 1000/s is not an issue like (point-read / point-write) data stores like dynamo
For issues "getting the article at 1000x/second" refer to "use cache" documentation which by default sets revalidation at every 15mins
@Belgian Hare <@271003779128754177> You can see cache documentation using "use cache" here.
https://nextjs.org/docs/canary/app/api-reference/directives/use-cache
What you're talking about though is "1000 people updating the article at the same time", "use-cache" on the component/function/file wont help here as it's a bottleneck on update speed not on speed to get the data.
I would in the first place why 1000 people are updating the same article / second this seems outrageous, then I would say this as an issue ethier fixed by a rate-limit to prevent updating articles more than say 60x/second or use a data storage system where updating 1000/s is not an issue like (point-read / point-write) data stores like dynamo
! VINKEOP
oh no sorry my english it's not to good 😅
in my plateform people can add item/remove item/ modify item... in ear own inventory
this is a inventory manager for resellers
My question is, when user update/add/delete item, for now i use server action to update DB and i use router.refresh() to get the new data, i just want to know if it is the normal way to do it on this type of application or if there is another better way.
Thank for your response 🙏
in my plateform people can add item/remove item/ modify item... in ear own inventory
this is a inventory manager for resellers
My question is, when user update/add/delete item, for now i use server action to update DB and i use router.refresh() to get the new data, i just want to know if it is the normal way to do it on this type of application or if there is another better way.
Thank for your response 🙏
and i'm using nextJS14 for now
Belgian Hare
Seems fine to me