Skip to main content
Known Participant
August 16, 2013
Question

Disabling GZIP Compression on CFM pages for Google Analytics Code

  • August 16, 2013
  • 1 reply
  • 1094 views

In order to put Google Analytics (GA) on all CF-generated pages, without having to edit 1000's of CFM pages, I am trying to use an IIS URL Rewrite Outbound rule to add the GA code. Outbound rules require no compression in order to do the equivalent of a search/replace on generated content. But CF is compressing the generated page, so the outbound rule fails.

THis is verified with a simple CFM page. With the outbound rule disabled, the CFM page loads correctly. With the outbound rule enabled, the CFM page returns a 500.52 errror. This is because the generated page is compressed. (Compression is turned off at the IIS site level).

This is with CF 9.01, Server 2008 R2, IIS 7.5, with URL Rewrite module installed.

1) Is it possible to turn off compression on CF-generated pages?

2) Is there a way to include the GA code on all CF pages, without  editing 1000's of files. Note that there are many different CF applications running on the server, so there is not one common application.cfm/cfc.

Thanks...Rick...

    This topic has been closed for replies.

    1 reply

    Carl Von Stetten
    Legend
    August 16, 2013

    Rick,

    Are you using Application.cfc in your applications?  If so, you could add the GA stuff to the end of the onRequest() method.  That should cause it to be executed on every page request  You might need to examine each request to make sure they aren't CFC or AJAX requests, but it should work.

    There may be a way to do it with Application.cfm too, but it's been so long since I've used it I can't say for sure.

    -Carl V.

    Known Participant
    August 16, 2013

    See #2 in the original question.....too many applications.cfm/cfc on that server, don't want to edit them all, and new apps are added all the time.

    Carl Von Stetten
    Legend
    August 16, 2013

    Yeah, I saw that.  You didn't say exactly how many applications you have running - editing a handful of Application.cfc files would still be preferable to editing thousands of CFM files overall.  But I recognize that you don't want to that either. 

    Just did a quick Google of "ColdFusion GZip Compression" and came across an article that talks about enabling GZIP in ColdFusion, which implies that ColdFusion doesn't apply GZip compression automatically.  You might take a look inside the web.xml file (in /ColdFusion9/wwwroot/WEB-INF and see if there are any GzipFilter entries in the servlet configuration.

    HTH,

    -Carl V.

    Message was edited by: Carl Von Stetten