从API获取数据时的客户端与服务器端 [英] Client Side vs Server Side When GET data from API

查看:58
本文介绍了从API获取数据时的客户端与服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从电影API中检索数据.

I'm retrieving data from a movie API.

现在,我可以在客户端(jQuery)上进行此操作,也可以在服务器端(Node.js)进行http get调用.

Now i can either do this in on client side (jQuery) or can make the http get call on the server side (Node.js).

这样做是否有最佳实践?一种选择比另一种更快吗?

Is there a best practice in doing this? Is one option faster than the other?

(由于可以隐藏我的API密钥,我正走向服务器端),但有兴趣确定.

(I'm towards server side as I can hide my API key) but interested to know for certain.

推荐答案

这样做是否有最佳实践?

Is there a best practice in doing this?

不是一般人

一种选择是否比另一种更快?

Is one option faster than the other?

在服务器端执行此操作可以将结果缓存并在多个客户端之间共享.这可能会更快.

Doing it server side allows results to be cached and shared between multiple clients. This might be faster.

在服务器端执行此操作可使客户端减少一个HTTP请求.这可能会更快.

Doing it server side allows the client to make one fewer HTTP requests. This might be faster.

在客户端执行此操作可以重做它,而无需重新加载整个页面.这可能会更快.

Doing it client side allows it to be redone without reloading the whole page. This might be faster.

在客户端进行操作意味着它来自另一台计算机,该计算机可能与发出请求的服务器更近或更远.这可能会更快.

Doing it client side means it comes from a different computer which might be nearer or further from the server the request is being made to. This might be faster.

这篇关于从API获取数据时的客户端与服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆