views:

36

answers:

2

I'm supporting a legacy application on ColdFusion 7, and the pages are full of painful amounts of whitespace that I'd like to gzip away.

I know I can:

  • manually compress everything in an index type file (reference)
  • enable it in the web.xml (which I don't have access to)

But can I just throw the right < cfheader > or something akin to a .htaccess that triggers gzipping on this directory?

+1  A: 

The only time I've seen CF handle GZIP itself, IIRC, is when using the internal (not for production) web server. I've always seen compression handled at the webserver (IIS or Apache) level.

If there is specific code that is dumping large amounts of whitespace, there are a number of options for dealing with it. Several are roughed out in an article by Ray Camden.

Personally, I don't worry about whitespace much unless it's really bad. I turn off output in CFCs (if something should be displayed, I return it), and I use CFSilent blocks around code blocks that shouldn't display output anyway.

Ben Doom
+3  A: 

There are two ways to implement compression. At the web server level (apache 1.3 with mod_gzip or mod_deflate, IIS_6, IIS_7) or the application server level (coldfusion via a servlet filter).

I'm afraid those are the only options available to you for compression.

Otherwise you'll be looking at one or more of these:

  • enabling whitespace suppression via cf administrator.
  • using <cfsetting enablecfoutputonly="true"/> where possible.
  • wrapping code with <cfprocessingdirective suppressWhiteSpace="yes"></cfprocessingdirective>
  • wrapping code with <cfsilent></cfsilent>
Mark