admin管理员组文章数量:1325236
I was wondering if anyone has done any testing on the speed differences of cURL and XHR (in regards to the time it takes to plete a request, or series of requests).
Specifically I'm wondering because I would like to use XHR to go to php script, and use cURL from there to grab a resource. The php page will ensure ensuring the data is in the right format, and alter it if it isn't. I would like to avoid doing this on the javascript end because it's my understanding that if the users puter is slow it could take noticeably longer.
If it makes a difference, all data will be retrieved locally.
I was wondering if anyone has done any testing on the speed differences of cURL and XHR (in regards to the time it takes to plete a request, or series of requests).
Specifically I'm wondering because I would like to use XHR to go to php script, and use cURL from there to grab a resource. The php page will ensure ensuring the data is in the right format, and alter it if it isn't. I would like to avoid doing this on the javascript end because it's my understanding that if the users puter is slow it could take noticeably longer.
If it makes a difference, all data will be retrieved locally.
Share Improve this question asked Jun 10, 2009 at 0:48 Ian ElliottIan Elliott 7,6865 gold badges36 silver badges42 bronze badges 2- 3 If all data is local, why are you using HTTP to get it? – acrosman Commented Jun 10, 2009 at 0:54
- I still need to pass items along to the data, and let it be processed. The 'data' are scripts that execute and return a response. – Ian Elliott Commented Jun 10, 2009 at 1:16
2 Answers
Reset to default 7There is no speed difference between the two. You're paring an HTTP request to an... HTTP request. For our purposes they both do the exact same thing, only one does it in JavaScript and one in PHP. Having a chain will take twice as long (probably more) since you're making a request to your server, and then your server is making a request to another server.
I don't understand why you wouldn't want to just get the resource with JavaScript and scrap the PHP median. I don't see any problem with doing it that way. (Unless your data is on another domain, then it gets trickier, but it's still doable.)
If I understand the question correctly, the difference will be that XmlHttpRequest would be on the client side (javascript), and cURL would be on the server side (PHP)
This would impact performance one way or the other, depending on where the resource is (you say local), and how many concurrent requests you'll get.
本文标签: phpXmlHttpRequest vs cURLStack Overflow
版权声明:本文标题:php - XmlHttpRequest vs cURL - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742168183a2426218.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论