Sunday, March 30, 2008

Prevent _IG_FetchContent from caching data

_IG_FetchContent is a Java Script function provided by Google for facilitating iGoogle's Gadget development. Its function is simply to fetch data from a HTTP location.
_IG_FetchContent('http://www.google.com/', function (responseText) {
// do something
}
);

However, the HTTP request is NOT directly send from client to web server of that location like most AJAX calls. Google itself cache the content too. Which cause problems for Gadgets which need dynamic data.

To prevent Google from caching the data, the third parameter which is refreshInterval has to be specified.
_IG_FetchContent('http://www.google.com/', function (responseText) {
// do something
}
,{ refreshInterval: 1 });
The '1' means that the content at this location is cached for one second. Which is a reasonable amount of time.

1 comment:

Giaime said...

Hello mr. Natthawut Kulnirundorn, I'm in the need of contacting you. Send me a mail at xgiaime at hotmail dot it, I need some information about your FPGA graphic project.

Sorry if I write here but the "contact" form on your website doesn't work. Thank you very much.
Giaime