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:
-
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.
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.
-
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.
-
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.
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.
3 Comments
Comments for this entry have been disabled.