Death to isDefined()
Feb/100
Ever come across a couple of lengthy stack traces in your ColdFusion logfile that start with something like “Error in blah – java.net.SocketException: Broken pipe”? Here’s what that’s about:
While isDefined() may be a convenient way to check the existence of a certain variable, you just should avoid it at all cost and use structKeyExists([SCOPE],”[variableName]“) instead.
Not only will structKeyExists() be much faster than isDefined(), as you’ve told ColdFusion where to look for your variable, so it doesn’t have to check through all available scopes. You’ll also avoid a lot of useless chatter clogging up your server’s log files.
Say you’re looking for a variable which at this point is in fact not defined in any of the available scopes and you’re using evil isDefined() to do the job. ColdFusion will scan all the available scopes and eventually it would check the CGI-scope, too. And here’s our problem: If the original connection from browser to webserver has already been closed in the meantime, which may happen for various reasons, the JRun connector (i.e. the bit that does the communication between webserver and the Coldfusion Application Server) will obviously fail to read the HTTP connection header and tell that tale in the log file in quite excessive detail, full stack trace and everything, although you really couldn’t care less about it.
So in essence: Just pretend you never heard of isDefined(). structKeyExists() ist so much nicer and will give you a warm fuzzy feeling all over every time you use it.
ColdFusion 8 and Symlinks – Hell Awaits? (solved)
Jul/093
UPDATE: The issue seems to be fixed with ColdFusion Hotfix hf801-71648 (see technote kb403629). The fix is included in the Cumulative Hot Fix 2 for ColdFusion 8.0.1 (see technote kb403781). My bad – I thought I had deployed the hotfix when all I had in fact done was upload the zip-file instead of the jar. Epic fail. Anyway, the technote is a bit misleading as well – it’s talking about Application.cfm path resolution when the same issue applies to cfinclude, too.
I recently stumbled over an issue when using symbolic links on a couple of ColdFusion applications. I intended to use symlinks to keep duplicate code between different applications to a minimum. I’m running Apache 2.2 with ColdFusion 8.0.1 on 64-bit Debian Etch. Each of our web-applications needs a “connector” while retaining an include with some site-specific config.
Using content compression with ColdFusion and SSI
Jun/090
This is actually an old story, just wanted to blog this so it might eventually help somebody else…
You probably know that most web-pages you’ll find nowadays don’t come as plain textfiles through this series of tubes, but the content is actually gzip-compressed server-side and unpacked by your browser, as long as the latter signals the server that it actually digests compressed content, which it usually does by sending the appropriate header.
Anyway, compressing static content is quite simple, you’d use something like mod_deflate with Apache2 or mod_gzip with Apache 1 and I am sure there are similar options for other webservers.
Compression of ColdFusion-generated pages is a little trickier though – mod_deflate doesn’t seem to help you here.