tags:

views:

149

answers:

3

I'm having a problem refreshing an xml file. I am bringing it in through an HTTP service component and putting it into a bindable array _cattArr, that I am using as the dataprovider for a grid.

When someone adds an item to the datagrid, it saves to the same xml file. Then I close the window, reopen it and don't see the item that has been added.

It is writing to the xml file, because when I restart the flex app, the item has been added, it's just not refreshing it. I have tried to resend the httpservice, but still no luck. What is the correct process for doing this?

+1  A: 

My guess is that the browser is caching the file, after all Flex and the Flashplayer are using the browser as a basis.

On the server side you could try to set no cache headers - this depends on your server.

On the client side there's various things you can do:

  • Use a POST instead of a GET, POSTs are not cached
  • attach a "version" number to the query string: http://server/file.xml?version=1234. If you use a new version for each request, the browser has to download it and won't serve it from the cache.
ilikeorangutans
thanks, all of these answers worked.
pfunc
A: 

As mentioned in the previous response, the easiest solution is to simply append a dummy random http param to the URL before making the HttpService call. e.g.

var hs:HttpService = new HttpService();
hs.url = "http://myserver/files/myXml1.xml?t=" + new Date().getTime();
//attach listeners to hs
hs.send();

This way you'll never get the cached xml from the browser. Thanks.

RR
A: 

Always append a random number to get new xml file..

Atul yadav

Atul Yadav