Daemonite: CFHTTP caching bug nailed Archive

Daemonite: CFHTTP caching bug nailed Archive


Wednesday, October 20, 2004
CFHTTP caching bug nailed

The underlying Java libraries that CFHTTP leverages caches DNS lookups indefinitely. For the 350 or so feeds aggregated by Fullasagoog this is like a handful of sand in the budgie smugglers. But it looks like we might have a fix.

Recently a customer complained about the behavior of CFHTTP in ColdFusion MX:

"CFHTTP permanently caches the DNS look-up. This cache can only be flushed by recycling ColdFusion service on the machine in question. Why doesn't CF rely on the server to resolve the domain? What's with caching the DNS look-up at all??"

Cue disgruntled customer... hey wait a minute that's my bug report! Turns out CF engineer supremo Tom Jordahl has dug around in the bowels of CFMX and found the obstruction...

Needless to say, the CFHTTP code doesn't do anything like this because it would make customers mad. :-) So I did a bit of investigation. The underlying library we use to support HTTP operations (after I switched it from using the Java URLConnection class, don't get me started...) uses the Java InetAddress class to look up host names:

http://java.sun.com/j2se/1.4.2/docs/api/java/net/InetAddress.html

Reading this page you will notice that the JDK caches both positive and negative DNS lookups. And it caches the positive lookups forever.

Hey, its not our fault!

Luckily, this can be controled by the Java security configuration for the JVM. In JDK 1.4.2 you can edit the file .../lib/security/java.security and set the value networkaddress.cache.ttl, commented out at the bottom of the file, to something other than -1. This controls the time to live for positive DNS results. There are dire security warnings about doing this, but something reasonable, like 4 hours (14,000 seconds), would probably be safe.

I am going to try and get a Tech Note published by support for this and perhaps mention this configuration in the CFHTTP man pages too.

With any luck Fullasagoog shouldn't skip so many beats every time a blogger changes IP address.

Posted by modius at 08:35 AM | Permalink
Trackback: http://blog.daemon.com.au/cgi-bin/dmblog/mt-tb.cgi/252

Comments

Thnx for the information and time and effort you guys put into the Goog :-)

Posted by: Owen van Dijk on October 20, 2004 08:57 AM

yeah, thanks for the info.

but what the heck does "like a handful of sand in the budgie smugglers" mean? what on earth is a handful of sand doing in a budgie smugglers? what the heck is a budgie smuggler?

Posted by: PaulH on October 20, 2004 01:12 PM

i also appreciate the goog more than you know. i check it several times a day, it saves me so much time from having to check all of those blogs. thanks again.

i also, would like to know what a budgie smuggler is

Posted by: Ryan Guill on October 20, 2004 01:31 PM