The solution to the problem that php post is too slow: first force the protocol to be 1.0; then send the header setting to "Expect"; and finally force the use of the IPV4 protocol to resolve the domain name.
Recommended: "PHP Video Tutorial"
php's curl function simulates post and get data submission, which is very fast Slow processing method
If you use the curl_setopt function to process remote webservices or capture pages, sometimes you will encounter a very strange phenomenon. The first access speed is abnormally slow, basically 5s- 10 seconds is a frustrating time.
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.
Let’s start with solving the problem:
1. curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); //The mandatory protocol is 1.0
2. curl_setopt($ch, CURLOPT_HTTPHEADER , array(''Expect: '')); //The header should send 'Expect: '
3, curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //Force to use IPV4 protocol to resolve domain names
The above is the detailed content of How to solve the problem of php post being too slow. For more information, please follow other related articles on the PHP Chinese website!