Recently I’ve been working with an extremely data intensive flight API which takes several seconds to process a response and up to 60 seconds to transfer the data.
Unfortunately there is no way to reduce the amount of content in the response which would have been the best optimisation. A good hint in cases like these is to try to get the server to compress the content. Using one simple CURL option I was able to speed up each request by around 40 seconds, extremely satisfying!
curl_setopt($curl,CURLOPT_ENCODING,'gzip');
If you’re actually creating the API using PHP, you may want to look at tweaking your php.ini settings to make sure zlib output compression is enabled.
You can also play with the output compression level, with 1 being the lowest and 9 the highest. Be careful however as a higher level of compression may result in high server load.
zlib.output_compression = On zlib.output_compression_level = 6