I'm currently learning how to separate frontend server and backend server. However, i'm not sure which approach should i take between the two
- Frontend server obtain data from backend server and adjust pages based on result
In this approach, user connect to frontend server, then frontend server connect with backend server and gives all the necessary information (user ip, cookie, post data, ect) to backend server. The backend server then return json and cookie data to frontend server. The frontend server then adjust the pages based on the data obtained from backend server, and set cookie on user browser. If there is redirect request from backend server, then frontend server redirect the user.
This approach is quite complicated because it require the frontend server to coordinate with backend server regarding what data should be sent to backend server. The latency arising from frontend server connecting to backend server is negligible because they're hosted on same server.
In this approach, when user connect to backend server it already send all the necessary data (post data, cookie data, user ip, ect), and so there is no need to redirect data unlike the first approach.
However the drawback of this approach is that it increases the speed at which webpage is loaded, because user need to download the page first from frontend server before actually connect to backend server.
When should i use the first approach and when should i use the second approach? is there other approach other than these two approach? Currently i'm learning on how to do it using xampp apache server running php, which approach is better for php server?
First of all, i haven't found any reference nor book on how to separate backend server from frontend server, and these two approach are just my guesses on how to do it. And so if these two approach are actually a bad approach and there are better approach to do it, then forgive me and feel free to tell me about it. If you have book or reference on how to separate backend server from frontend server, then can you please tell me about it ? thank you.