问题
My colleague have disabled dns caching in Android application. But we have to check whether we really disabled caching. Do you have any ideas how to check it?
We used the next commands to disable it:
System.setProperty("networkaddress.cache.ttl", "0");
Security.setProperty("networkaddress.cache.ttl", "0");
ps: this disabling is needed for automation tests.
回答1:
Its working. I've tested it connecting to a servers url with a dynamic IP. Before it took 2 hours until it could resolve the changed IP. after adding your code it resolved the new IP imm
回答2:
My guess is that Yaniv is seeing what Yaniv wants to see: If you grep the Android source code for networkaddress
you can see that it only appears in some Apache Harmony test code. That is, it doesn't seem like Android uses the networkaddress.cache.ttl
setting(s).
回答3:
Android not support that way, change dns cache when android 4.0, can't change dns ttl
it is answer
来源:https://stackoverflow.com/questions/9875379/check-disabling-of-dns-caching-in-android