开发者

what is the purpose of Java level DNS caching?

Currently I am working on an Android project. I have a doubt regrading java level DNS caching. Through search, I came to know that through calling the below ment开发者_JAVA技巧ioned functions we can achieve it.

 System.setProperty( "networkaddress.cache.ttl", "0" );
 System.setProperty( "networkaddress.cache.negative.ttl", "0" );

Based on this, it caches name look up data or not. I want to know the purpose or impact because of this property.


The purpose is to do less DNS requests. That results in quicker download because the IP for a hostname is allready in cache.

This are Java system properties that have effect directly to the standard network library. It allows you to tune the Java level DNS caching.

As all caching, caching has sometimes not desireable effects, such as the cache get updated late when some DNS entries has changed.

I consider values such 0 (no cache) or -1 (cache forever) only for testing purpose.


Also I don't think you can set the properties as above. On the JVMs you need to use

java.security.Security.setProperty("networkaddress.cache.ttl" , "10");

(not sure about Android)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜