Home>Article>Backend Development> How to solve the problem that curl transfers data too slowly in php
How to solve the problem that curl transfers data too slowly in PHP?
If you use thecurl_setopt
function to process the remote webservice or crawl the page, sometimes you will encounter a very strange phenomenon. The first access speed is abnormally slow. Basically it takes 5s-10s for people to collapse.
But no matter how much I check, I can’t figure out where the problem lies. I recently found an article about how to deal with this problem.
Start by solving the problem:
1、curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); //强制协议为1.0 2、curl_setopt($ch, CURLOPT_HTTPHEADER, array(''Expect: '')); //头部要送出'Expect: ' 3、curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); //强制使用IPV4协议解析域名
Related references:php tutorial
The above is the detailed content of How to solve the problem that curl transfers data too slowly in php. For more information, please follow other related articles on the PHP Chinese website!