Let say, user A has the name of 'James' and trying to change it to something else like 'John'. It might be stupid to ask this question but how do you apply this change?
I retrieve the new data from database and send back to Frontend to rewrite the data. However, it seems like it could increase network traffics. I was thinking like, storing the value inside the frontend and then the backend signals success or failure with the HTTP status codes. Then, rewrite data inside the frontend.
However, what I made a mistake and there is a difference between actual database and the state inside the frontend.
First of all, apology for unclear question in the beginning. So, my question is, how to deal with the updated data between front and backend.
As user update some field like his or her name. When, user does that, the frontend post-requests to the backend with the necessary data. However, the
name variable is also stored in the frontend's state. When the backend responses with
200, then use that frontend-stored variable to update the frontend's
name state. I thought this would save some network traffic sending back the data for large-scale websites.
Currently, I've doing with the 2nd method. Get the updated data from the backend and send back to the frontend with the response. And then, the frontend just rewrites with the data.
I was just wondering how websites would take care of this. After watching optimization videos that for a large scale site, even few kb matters in order to boost up the speed.
Again, I am sorry for the unclear question in the beginning. And, hopefully this would clear up my questions.