The miscellaneous ramblings and thoughts of Dan G. Switzer, II

ICU4J's TimeZone Ids Mapped To Windows Timezones

Ok, I've been working on trying to optimize some code recently. One of the huge bottlenecks in the application is the conversion of date/times to local user times. All date/times are stored in GMT in the database and are converted to user local when displayed.

We've been using a database table to do lookups/conversions of the date/times to make sure they display correctly depending on the user's region and whether or not they are in a daylight savings time. We're using custom data tables—which we have to maintain—not to mention it runs pretty slow on large recordsets.

In order to speed things up, I've been looking at using IBM's ICU4J's TimeZone class. Paul Hastings has written some nice little ColdFusion wrapper CFCs for this class. So far in my testing, under load the Java class performs about 10x more efficient that the db lookup code.


CFHTTP "Connection Failures" issues with Gzip

I've been playing around with Port80's Gzip compression filter, httpZip, on my development server and realized I was having a problems with CFHTTP calls. A quick search on Google pulled up a blog post by Steven Erat titled Workaround for CFHTTP and Compressed HTTP Response from IIS.

My problem differed slightly in that the very first request to a URL (via a CFHTTP request) works fine, but subsequent hits return a "Connection Failure" error. Unfortunately Steven's suggestion didn't work for me, but after some playing around with syntax I was able to come up with some solutions that do work:

  1. When configuring httpZip, set up all compressed mime types to exclude anything with the header "ColdFusion" and "CFSCHEDULE". This will fix the issue with any default CFHTTP calls (Schedule Tasks, CFCACHE, or CFHTTP calls where no "user agent" is specified) If you're manually setting the "user agent" in the CFHTTP call, see one of the following solutions.
  2. NOTE:
    After some more testing, it appears CFMX 7 reports the user agent string of "CFSCHEDULE" and not "ColdFusion". This means you should also add the "CFSCHEDULE" string along with the string "ColdFusion" to your MIME type exceptions list.
  3. Pass in a <cfhttpparam type="header" name="Accept-Encoding" value="*" />. For some reason Steve's suggestion did not work for my setup, but passing in the asterisks value did work. Including this header information prevented me from getting the "Connection Failure" message again.
  4. The last method is to add custom header to the page serving up content, which tells the httpZip ISAPI filter to ignore compressing the request: <cfheader name="httpZip" value="no-compression" />. You could use this technique and have all your CFML pages look for the custom header labelled "Gzip-Disabled". If the custom header exists and is set to "true", you then could execute the CFHEADER tag to tell the ISAPI filter not to compress the page. This would give you the ability to dynamic control the compression of httpZip from within your code.
  5. NOTE:
    You could pass in the httpZip to your initial call and just pass that value back to the CFHEADER output stream, but that opens your page up to be controlled from an outside source. I prefer to just allow the compression to be enabled or disabled on request.