10 messages in com.googlegroups.google-gadgets-api[Google-Gadgets-API] Re: Caching issu...
FromSent OnAttachments
Artyom Ch.27 Jun 2008 07:47 
Jerome (Guru)28 Jun 2008 15:53 
Artyom Ch.28 Jun 2008 19:38 
chandan.a. singe28 Jun 2008 20:12 
นายบุญชัย แสงจันทร์01 Jul 2008 11:11.jpg
นายบุญชัย แสงจันทร์02 Jul 2008 09:07.jpg
jamim10 Jul 2008 13:59 
Justin McConnell10 Jul 2008 16:55 
Jerome (Guru)10 Jul 2008 17:51 
Kevin22 Aug 2008 18:26 
Subject:[Google-Gadgets-API] Re: Caching issues when using _IG_FetchXmlContent
From:Jerome (Guru) (jero@gmail.com)
Date:07/10/2008 05:51:13 PM
List:com.googlegroups.google-gadgets-api

Hi Artyom,

I would recommend not using a time stamp as your unique key. This works well with only one user, but when you have many concurrent client, each with a local computer clock not exactly adjusted, this will lead to unexpected and hard to debug issues.

Jerome

On Jun 29, 4:38 am, "Artyom Ch." <arty@gmail.com> wrote:

Hi Jerome ,

Thank you for the reply! Yes, the first thing that I did to resolve the problem is adding the '? r='+Math.random() to the XMLs URL. I just thought that the issue can be resolved in a more conventional way.

I found even better solution: to use the previously received timestamp as a "random" parameter for each subsequent request. This way I can set the refreshInterval to non-zero value and allow Google to cache results even for hours since each URL with the timestamp is actual just for 15 seconds. The Math.random() is used just for the very first request to ensure getting the most recent XML.

Artyom.

On Jun 29, 1:53 am, "Jerome (Guru)" <jero@gmail.com> wrote:

Hi there,

I experienced similar issues with the _IG_Fetch...() function, trying to get a short caching was leading to getting data from a few seconds to minutes old. To avoid this issue, what I do when I must have very recent data in a gadget is: - setting the refresh interval to 0 - appending a random value to the URL being fetched, like for
instancehttp://www.iggamecenter.com/xmldata/games/list0.xml?random=2485439830... (of course, replace 24854398304985 with a automatically generated random value with Math.rand())

This is putting more stress on the Google proxy and on my backend servers, but this will ensure that the fetchers do their best to get fresh data for the gadget. Of course, if the fetchers get overloaded, you might have time outs or get old data anyway.

I hope this helps.

Jerome

On Jun 27, 9:47 am, "Artyom Ch." <arty@gmail.com> wrote:

I have a gadget that fetches an external XML file every ~15 seconds using _IG_FetchXmlContent function. The third parameter of the function explicitly sets the cache refresh interval to 15 seconds: { refreshInterval: 15 }

It worked well till the last 3 days. During the last three days the gadget has been randomly getting old cached copies of external XML. Sometimes it gets copies, which are 1 hour old. Setting refreshInterval to zero doesn't help. I open the XML file in a browser window and see how it updates every 15 seconds when I manually refresh the page. But the gadget keeps receiving old copies.

I asked other gadget users whether they experience the same problems and got a positive answer.

I created a test gadget for reproducing the problem. The gadget is embedded in the following page:

The gadget fetches the following XML:

every 15 seconds and prints a value of "timestamp" attribute of "GameSessionList" tag. The XML file is updated by server every 15 seconds so the "timestamp" attribute should increment by 15 each 15 seconds. You can see it yourself by opening the mentioned XML file in a browser and refreshing it manually.

However, the gadget prints "timestamps", which values are randomly spread over the last hour. I.e. the "{refreshInterval:15}" doesn't work.