获取数据并将其发布到外部Web API(服务器端还是客户端)?

时间:2018-07-24 09:38:14

标签: django reactjs model-view-controller flask

我正在开发一个网络应用程序,该应用程序的一个部分用于从外部API(例如usgs和google-maps)获取一些数据,并将其显示给用户,另一个部分用于从用户获取输入(例如几个输入)字段)并将其发布到其他API。

我可以使用Django / Flask在服务器端进行操作,而使用Reactjs(或香草js,引导程序等)在客户端进行操作。

在 在速度,安全性和用户友好性方面,我应该在哪里进行这些API调用?服务器端还是客户端? 我是否想将某些数据保存到服务器上,这有什么区别?

1 个答案:

答案 0 :(得分:2)

Security

In terms of security, if you are doing API calls on server which requires API key then it's not good practice to reveal it in client side. Hence, if that's the case then doing API call in server side will be better option. Apart from that and as per my knowledge there is no security issue in making API calls.

Speed

In terms of speed,

  • If the data to be fetched is common to all the clients, then making API call and cacheing it in server side may increase speed
  • For the changes which reflect to client side on real time, API call in server side will lead to page reloading, hence at this point it will be best to do API call in client side
  • Sometimes location also matter, like client may be near to the server where API call is being made, at this case it can be faster, but it doesn't help

User Friendliness

As per the user friendliness, i don't think it matters either way, coz speed is covered. So, apart from that it won't make any difference to client as per my knowledge

Thanks,

This is just from my point of view and knowledge, if there is more or i am wrong in some point, please correct me