Search code examples
phpjquerytwitterclient-sideserver-side

Ajax calls vs. server side calls


I am building a twitter feed widget for Wordpress, and one of the issues I have to deal with is Twitter's rate limits (150 tweets per hour per account). I have noticed that when i'm fetching the tweets using server-side calls (e.g. file_get_contents()) the limit is reached very quickly, especially on a shared host. I've tried to fetch the tweets using client-side calls with jQuery's getJSON function, and the rate limit took a lot longer to reach.

  • What is the reason for this difference between client-side and server-side calls when it comes to Twitter rate limits?
  • Which method would be preferable for this case?

Update
I should note that the tweets are being cached to avoid hitting the rate limits, but that does not help when the calls are made from a shared host.


Solution

  • When you use server-side calls, all the calls are coming from the same IP; all the users are sharing the same 150 tweat/hour quota.

    When you use client-side calls, they calls come from different IPs for each client. Each client gets 150 tweats per hour, so all the clients combined can get a much larger volume.