Support | Contact Us
Search:

Leverage Google Feedfetcher for AJAX RSS Readers

Share: More

Let's say you're making a website and you want to display the 10 latest posts from your favorite blog in a sidebar on your site. There are several approaches that can be taken. They all have positive points and negative points.

The first approach you could take is to make your server do all the work. You could have your server grab the RSS feed on page load and transform it to HTML to put onto your page. Sure, that works but it means your server is loading the feed every single time someone views the page. This is extra work for your server to do and it's going to slow down the page load as well as possibly anger the website owner on the other end who you’re querying every time your pages load.

You could take that one step further and have your page load the feed by making a proxy page on your server to load the feed through. This is the same as the previous approach, except you're cutting down on the page load since the feed will be loaded via AJAX after the page has been loaded. However, you're still making your server do the work of retrieving and caching the feed itself increasing your bandwidth usage.

Wouldn't it be nice if you could just make the users' browser load it directly through AJAX by talking to the destination server on its own and retrieving the feed directly? Of course it would, but that raises serious security implications and due to browser same origin policy restrictions, it's technically impossible with traditional RSS (having the feed in JSON form and using a callback is the exception).

Well, have no fear, because the Google AJAX Feed API is the answer to all of the above problems! Here's how it works. First, you import Google's main Javascript API. Then, you call the AJAX RSS load function and Google returns back a beautiful JSON object (or an XML document) that you can transform into HTML any way you'd like to! The best part is it takes the load off of your server and puts it into the users' hands by having their browser talk directly to Google's Feed Cache to retrieve the feed quickly and efficiently.

I know what you're saying, you're saying "GOOGLE HAS DONE IT AGAIN, THEY SAVED THE DAY!" Hold on, hold on, there's always a downside. The AJAX Feed API makes use of Google's Feedfetcher caching service (which also powers Google reader) and it caches specific feeds based upon a popularity contest of sorts. The more people that request a given feed (through the API or Google Reader itself), the more often Feedfetcher grabs the latest version of the feed to put into its cache. This typically means that Feedfetcher crawls most feeds approximately once per hour (more popular feeds being crawled more often than that).

So, how can you actually make use of this and see it in action? Right here on our website! We make use of the Google AJAX Feed API right on the home page of our site in the "Latest Tweets" section. The Twitter search API allows us to send a query to them, in this case, "give me the latest tweets from this specific list of users with the hash tag #nimble" and it gives back an RSS feed. We load this RSS feed through a search query via the Google AJAX Feed API and voila, instant tweets with no Twitter API rate limiting worries and no server side code doing the work. Of course, this also means that the tweets aren't displayed immediately after they're posted on Twitter, but we get good sample group of the tweets within the last hour updated fairly frequently.

For more information on how to make use of this great service, check out the API documentation and implementation samples on the Google AJAX Feed API website.

Care to Comment?

© 2010 NimbleUser • 656 Kreag Rd. Pittsford, NY 14534 • 585.586.4750