File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes DNS Caching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "DNS Caching" Watch "DNS Caching" New topic

DNS Caching

Michael Hedrick

Joined: Jan 26, 2005
Posts: 3
Are there any Tomcat configuration parameters that would stop Tomcat from caching DNS values? We are trying to implement a environment where JSP pages are hosted on a Windows 2003 server running Tomcat 5.0. The JSP makes SOAP/RPC web services calls to retrieve information from back-end systems. The URL in the web service goes through a BigIP sprayer which distributes the request to an available resource. After the first call, the DNS is getting cached somewhere and subsequent calls are being directed to the same resource.

We have already modified the MaxCacheTtl registry on the Windows 2003 server to only hold the DNS for 1 second. Also the time-to-live for the DNS on the BigIP sprayer is 10 seconds. The distribution has been successful when a making the requests from other applications (Internet explorer and LoadRunner), but we've had to luck with Tomcat hosted JSPs.
Matthew Amacker

Joined: Aug 10, 2004
Posts: 5
Hey Michael,
The InetAddress class caches name resolution values to prevent spoofing. Check out:
InetAddress (Java 2 Platform SE v1.4.2)

That article explains that you may want to set:

Hope this helps.
Michael Hedrick

Joined: Jan 26, 2005
Posts: 3
Hi Matthew,

Unfortunately, we have already tried those class setting previously with no apparent affect.

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

We have also set the "Cache-Control" property in the SOAP header to "no-cache", which also has not resolved the issue.

Any other ideas? At this point, we're really scratching our head on this one.

Michael Hedrick

Joined: Jan 26, 2005
Posts: 3
We ended up finding the solution to this issue. There is a utility in the bin directory that allows you to modify Tomcat configuration parameters. Below is the steps taken to implement.

Stop Tomcat
Go to tomcat\bin
Run Tomcat5w.exe
Goto java tab
Add java property to java options section
Start Tomcat

The same java option was placed in the JSP itself with no affect, it had to be in the Tomcat configuration to be effective.

Hope this helps someone else down the road.
I agree. Here's the link:
subject: DNS Caching
It's not a secret anymore!