iOS 上的多个 HTTP 请求与单个 TCP 连接
我正在开发一个 iPhone 应用程序,它使用我控制的基于 Web 的 API。连接到持续打开的 TCP 端口并通过 TCP API 发出请求,或者为我想要获取的所有数据发出新的 HTTP 请求,会更快或更高效吗?
我认为差异可以忽略不计,但我可能是错的。
每次加载新视图时都会获取新数据,因此请求可能会相当频繁地发生。
I am developing an iPhone app that uses a web based API that I control. Would it be faster or more efficient to connect to a constantly open TCP port and make requests via the TCP API, or make a new HTTP request for all the data that I want to fetch?
I am imagining that the different would be negligible, but I could be wrong.
New data is fetched pretty much every time a new view is loaded, so requests can happen fairly frequently.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为差异很小。
还值得注意的是,NSURLConnection 默认支持 HTTP Keep Alive 连接,因此您可以直接使用 HTTP 并确保您的服务器允许客户端保持连接处于活动状态。
I think the difference would be minimal.
It is also worth noting that NSURLConnection supports the HTTP Keep Alive connections by default, so you could go straight HTTP and make sure your server is allowing the client to keep the connection alive.