file_get_contents() with context to use http/1.1 significantly slow download speeds

后端 未结 2 1730
栀梦
栀梦 2021-01-12 12:25

Using the code below each image download) file_get_contents() ) takes on average 8-15 seconds.....

If I do not use a context on file_get_contents() then image down

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 12:58

    HTTP 1.1 requests are pipelined by default. If you don't "Connection: Close", it assumes "Connection: Keep-Alive", and then you have to wait for the connection to time out (since you never explicitly closed it) before the next loop will start.

提交回复
热议问题