Home > Backend Development > PHP Tutorial > 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

WJ
Release: 2023-04-08 20:38:02
Original
3336 people have browsed it

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 the curl_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协议解析域名
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template