I have a very simple PHP CURL get request to retrieve a json file from my AWS CloudFront distribution.
public function get_directory() {
$json = 'https://d108fh6x7uy5wn.cloudfront.net/themes.json';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $json);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$array = curl_exec($curl);
curl_close($curl);
$array = json_decode($array, true);
$array = $array['themes'];
return $array;
}
I then have a foreach loop which displays the information contained in the json file.
However, it takes over 120 seconds for the page to load, it's VERY slow. If I use my S3 origin URL instead of the CF URL the page loads instantly.
I am using this same method on other servers without any issues. The issue only occurs on this server which is using the InterWorx hosting control panel software.
The code resides on the server as a plugin for InterWorx, so located here /usr/local/interworx/plugins/wordpress
It seems it could be an issue with my CF distribution settings however I am a bit of a noob when it comes to AWS and am at a loss.
If anybody can point me in the right direction that would be greatly appreciated.
@Brettski@AWS I opened up my Chrome Developer Tools in the Network tab and noticed the Time To First Byte (TTFB) is 3.6 minutes. This ONLY occurs when I use my CloudFront distribution URL, it loads quickly with my S3 URL. Could this be due to a setting in my CF distribution behavior settings? Cache policy and origin request policy?
This is the log result when I turn on VERBOSE for the curl get request:
< HTTP/1.1 200 OK < Content-Type: application/json < Content-Length: 68529 < Connection: keep-alive < Last-Modified: Tue, 21 Dec 2021 12:05:12 GMT < Accept-Ranges: bytes < Server: AmazonS3 < Date: Thu, 2