php - file_get_contents/curl 阻止其他客户端

标签 php apache curl

我使用 file_get_contents/curl 从我的 php 脚本访问另一台服务器上的一个 API。此 API 速度不快,最多可能需要 10 秒才能响应。

当我尝试在使用此 API 的网站上同时打开 2 个页面时,它们会一个接一个地加载,即我需要等待第 1 个页面加载完毕,然后服务器才会开始向服务器请求第 2 个页面。

我在linux下使用Apache2和php。 我如何避免这种行为,我不想在其中一个客户端访问此 API 时阻止其他客户端。需要帮助!

谢谢。

最佳答案

是的。

有这个 PHP 库:http://code.google.com/p/multirequest/(这是一个多线程 CURL 库)。

作为另一种解决方案,您可以使用支持线程的语言(如 Ruby 或 Python)编写一个脚本来执行此操作。然后,只需用 PHP 调用脚本即可。看起来很简单。

关于php - file_get_contents/curl 阻止其他客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19355972/

相关文章:

PHP Curl 连接至 Amazon MWS 卖家 API

php - 谷歌云存储 : Upload Object is returning HTTP/1. 1 100 继续

php - 需要 ext-fileinfo。如何将其添加到我的 composer.json 文件中?

php - Magento 中的“news_from_date”

apache - 错误代码 : 502 Proxy Error. ISA 服务器拒绝了指定的统一资源定位器

regex - 将 http 重定向到 https OS X Server 5.0.15

javascript - react JS : Map over an array of objects to render in JSX

php - "elseif"和 "else if"完全是同义词吗?

Apache 反向代理直接将浏览器发送到后端

C++ 将静态库添加到 CMake 项目导致 undefined reference