PHP file_get_contents very slow when using full url

后端 未结 9 1075
我在风中等你
我在风中等你 2020-11-27 12:10

I am working with a script (that I did not create originally) that generates a pdf file from an HTML page. The problem is that it is now taking a very long time, like 1-2 mi

9条回答
  •  忘掉有多难
    2020-11-27 12:50

    I know that is old question but I found it today and answers didn't work for me. I didn't see anyone saying that max connections per IP may be set to 1. That way you are doing API request and API is doing another request because you use full url. That's why loading directly from disc works. For me that fixed a problem:

    if (strpos($file->url, env('APP_URL')) === 0) {
        $url = substr($file->url, strlen(env('APP_URL')));
    } else {
        $url = $file->url;
    }
    return file_get_contents($url);
    

提交回复
热议问题