SOS

Shane O'Sullivan's technical blog… really ties the room together

Use YQL to cache your queries

Posted by Shane O'Sullivan on August 5, 2010

Quick tip: For faster access to remote data, you can’t beat using Yahoo’s YQL to cache your data.  See HERE to read more on this.

When accessing data from remote services, e.g. Flickr, often the data won’t change too frequently.  Some data can also be very expensive to generate, and services forbid you from polling it on a regular basis.  For example, a device is not allowed to retrieve the latest activity on a users Flickr account more than once per hour.

You could roll your own solution to this problem, store the data locally and check its timestamp.  However, this is a lot of work for something that can be so much simpler.

Simply access the XML or JSON data using the Yahoo Query Language, and set the _maxage parameter to the length of time you want to cache the data for.  And you’re done.  Yahoo will cache the data for you, refresh it when the specified time elapses, and serve it to you faster than the original query since it doesn’t have to calculate anything.

Also, the service provider will be happier as you’re not hitting their server so often for duplicate data.

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 533 other followers

%d bloggers like this: