禁用Java DNS缓存-Disable DNS caching
Once an application has performed network access (i.e. urlconnection, parsing of xml document with external references, etc), the DNS settings get cached so any subsequent operation will use the old settings even if the real settings have changed. To reset everything, you have to restart the server since the the default setting JVM setting is to cache forever.
There are 4 properties that can be used to override the default behaviour.
networkaddress.cache.ttl (default: -1)
Specified in java.security to indicate the caching policy for successful
name lookups from the name service. The value is specified as as integer
to indicate the number of seconds to cache the successful lookup. A value of -1 indicates "cache forever". networkaddress.cache.negative.ttl (default: 10)
Specified in java.security to indicate the caching policy for un-successful
name lookups from the name service. The value is specified as as integer to
indicate the number of seconds to cache the failure for un-successful lookups. A value of 0 indicates "never cache". A value of -1 indicates "cache forever". sun.net.inetaddr.ttl
This is a sun private system property which corresponds to networkaddress.cache.ttl.
It takes the same value and has the same meaning, but can be set as a command-line
option. However, the preferred way is to use the security property mentioned above. sun.net.inetaddr.negative.ttl
This is a sun private system property which corresponds to networkaddress.cache.negative.ttl.
It takes the same value and has the same meaning, but can be set as a command-line option.
However, the preferred way is to use the security property mentioned above.
So you can disable caching by adding -Dsun.net.inetaddr.ttl=0 on the command line starting the JVM. But you can't set the value of networkaddress.cache.ttl on the command line. You can set the required value in the java.security file located in %JRE%\lib\security
networkaddress.cache.ttl=60
networkaddress.cache.negative.ttl=10
or set the value in your code with
java.security.Security.setProperty("networkaddress.cache.ttl" , "0");
禁用Java DNS缓存-Disable DNS caching的更多相关文章
- 浏览器 DNS缓存与DNS prefetch (DNS预解析)
浏览器 DNS缓存 浏览器DNS缓存的时间跟DNS服务器返回的TTL值无关. 注:TTL(Time-To-Live),就是一条域名解析记录在DNS服务器中的存留时间. 浏览器在获取网站域名的实际IP地 ...
- Linux在shell终端中清空DNS缓存,刷新DNS的方法
现在很多Linux发行版都没有内置DNS本地缓存,Linux不像Windows那样可以使用ipconfig /flushdns来刷新,在Linux下无需刷新,因为本身没有缓存. 前言 在Linux系统 ...
- 域名解析的DNS缓存如何清理
域名解析(DNS)缓存是什么? 域名解析缓存又名DNS缓存,常见表现名称是TTL:(TimeToLive)生存时间,就是域名解析记录在DNS服务器中的存留有效时间. 当各地的DNS服务器接受到解析请求 ...
- Linux设置DNS地址及清理DNS缓存方法
1.设置DNS地址 编辑vim /etc/resolv.conf 文件. 增加DNS地址:nameserver ip. 2.清理DNS缓存 清理dns缓存: 通过重启nscd服务来达到清理dns缓存的 ...
- 清理dns缓存
dns缓存是什么? DNS缓存指DNS返回了正确的IP之后,系统就会将这个结果临时储存起来.并且它会为缓存设定一个失效时间 (例如N小时),在这N小时之内,当你再次访问这个网站时,系统就会直接从你电脑 ...
- windows查看与清理dns缓存
1.windows下在命令行输入 ipconfig /flushdns 清理本地dns缓存查看dns缓存 ipconfig/displaydns2.Mac OSX下在命令行输入 lookupd ...
- 通过JAVA反射修改JDK1.6*当中DNS缓存内容
时间 2012-05-28 17:09:03 Taobao QA Team原文 http://qa.taobao.com/?p=15523 为了实现性能压测时的域名动态绑定功能,尝试通过java反 ...
- Java 内存级默认DNS缓存
Java 默认的DNS缓存时间,即不设置任一系统属性,如networkaddress.cache.ttl 设置SecurityManager 默认的CachePolicy为Forever,即永久缓存D ...
- 浏览器的DNS缓存
通过设置hosts文件可以强制指定域名对应的IP,当修改hosts文件,想要浏览器生效,最直接的方法关闭浏览器后重新开启:如果不想重启浏览器,只需要清空浏览器的DNS缓存即可.清空DNS缓存在chro ...
随机推荐
- 保护眼睛,绿豆沙颜色的RGB值和HSL值
现在的人尤其是职场中人,每天都得花很长时间对着电脑,对眼睛的伤害很大,其实我们可以对电脑进行一个简单的设置,把窗口背景设置成绿豆沙颜色的,对眼睛的保护很有帮助的. 下面是绿豆沙颜色的RGB值和HSL值 ...
- MS SQL:ID自增列从1开始重新排序
数据库中把ID自增长重置成1: 一般做法:(太麻烦) 复制表数据->删除原表.新建一张表->粘贴: 新方法: 数据库中:新建查询->复制.粘贴一下代码->修改表名,执行即可(先 ...
- iOS小知识点大杂烩
转自OPEN经验 1,打印View所有子视图 po [[self view]recursiveDescription] 2,layoutSubviews调用的调用时机 * 当视图第一次显示的时候会被调 ...
- C和C++运算符 (转)
这里是C和C++语言的运算符列表.所有列出的运算符皆含纳于C++:第三个栏目里的内容也使用C来描述.应当注意的是C不支持运算符重载. 下列运算符在两个语言中都是顺序点(运算符未重载时): && ...
- 创建以及加载模块【nodejs第四篇】
建立两个文件,文件一createModule.js ,文件二main.js createModule.js的代码,主要用于创建一个模块 /** * Created by Administrator o ...
- C++结构体中sizeof
说明: 结构体的sizeof值,并不是简单的将其中各元素所占字节相加,而是要考虑到存储空间的字节对齐问题.这些问题在平时编程的时候也确实不怎么用到,但在一些笔试面试题目中出是常常出现,一.解释 现代计 ...
- 3n+1
#include<iostream> using namespace std; int main() { int n; while(cin>>n) { int count=0; ...
- leetcode String to Integer (atoi) python
class Solution(object): def myAtoi(self, str): """ :type str: str :rtype: int "& ...
- Ubuntu14.04 64bit安装Android-Studio
用PPA安装Android-Studio炒鸡简单,墙内亲测可用,就是速度慢了点.(睡觉时开着电脑装-) 安装Android-Studio 打开Terminal,执行: sudo add-apt-rep ...
- 数组求最大最小值和排序java实现
public class ArrayDemo05 { public static void main(String[] args) { int list01[]={67,89,87,69,90 ...