Home  >  Article  >  Backend Development  >  How to solve the problem of php post being too slow

How to solve the problem of php post being too slow

藏色散人
藏色散人Original
2020-10-20 09:47:312861browse

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.

How to solve the problem of php post being too slow

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn