2 years ago

#58232

test-img

Hans Desjarlais

CURL get request from server to AWS CloudFront very slow response time

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.

php

amazon-web-services

curl

amazon-cloudfront

php-curl

0 Answers

Your Answer

Accepted video resources