I'm pretty confused about how should Manage the data in the RESTful web application I develop. How much of the data should be saved on client side?
For a more specific example:
My application sends letters from one system to another. I save the letters on server side using Sql server. For each letter there are destinations and the source represented by Address object containing full information about the the Addresses. I can't decide how should I manage the data of the Addresses in my application, should I:
load all the Addresses to my client on start up and with each letter sendding stick the entire Addresses list to the reqeust? The request will contain more data and be bigger but I won't need to get all the stations on server
load to client only the Id's of the addresses and send requests with Ids and then load them from a database on server side? Requests will contain smaller amount of data but I will need to fetch all Addresses on server
Should I save on the client only the Address object representing his own Address and the other stations id's? Same as 2 but I won't need to fetch the Address of the sender
What are the pros/cons of each method? What would you choose in case the number of stations is around 100 (without so much data within each object)
I'm no professional so please correct me if anything I said was wrong/silly wording
Thanks in advance.
There is no silver bullet that works in all cases but i would suggest you to do it in next way:
Client should not send full address object as it might be (accidentally or by purpose) wrong.you should better always take real and valid data from DB. If you need to reduce load on DB you should better use server side caching. Example: