views:

316

answers:

1

AIR seems to keep its own DNS cache when an application is running, and ignores any changes to the OS DNS cache (i.e. ipconfig /flushdns).

More specifically, I'm creating multiple URLStream & URLRequest objects over a long period of time in a AIR application. Once the first one connects the host's IP address is cached for the lifetime of the application. And the URLRequest.useCache property, understandably, has no effect on DNS caching.

Does anyone know if it's possible or how to force a host name to re-resolve inside a AIR (or Flash) application?

Note: Unfortunately, resolving the IP through a web service and rewriting the URL is not an option as a workaround. The use-case is downloading files from Amazon S3 using signed URLs which are invalidated if modified.

Update: The test results above were gathered on WinXP prior to AIR 1.5.2. Subsequent tests using 1.5.2 show serialized requests with URLStream.load() are re-resolved more frequently but still ignore TTL values. I still haven't figured out what conditions are necessary to trigger the re-resolution, but have noted a couple of cases that prevent it. For instance, if another asynchronous URLStream is active to the same host then requests use the cached IP address and are not resolved. And simply closing and dereferencing all streams to a host is not sufficient to ensure the same host name will be re-resolved in the next request.

A: 

This is not a definitive answer, but it appears you can remove an entry from AIR's DNS cache by making one or more requests to other hosts-- thus overwriting the target host name in the cache. The next request to the target host name will then be resolved.

It's still unclear to me just how many entries can be held in the DNS cache though. So the number of other requests may vary, and that makes this technique questionable.

John Lemberger
AIR 1.5 on Mac OSX does not appear to suffer from the caching issue like AIR on WinXP.
John Lemberger