I've done some investigation on cURL and file_get_contents and from what I've read, cURL is a lot faster (see here: https://stackoverflow.com/questions/555523/file-get-contents-vs-curl-what-has-better-performance)
But now I'm wondering about the performance speed on getJSON? I'd like to know for future reference.
Thanks!
One runs on the server, the other runs on the client. This makes it primarily dependent on the internet speed of those two.
I'd say that doing it on the server is faster, but that it's probably better do it on the client if possible, since that would mean your server doesn't have to do too much work.
However, this is all analyzed from the user's perspective in actual time. The big advantage of using getJSON
is that you can show the user that you're loading, which is a lot harder with file_get_contents
. While the PHP solution may be faster, the user will think that getJSON
is faster, since he/she gets feedback during the load.