Welcome!

You will be redirected in 30 seconds or close now.

ColdFusion Authors: Yakov Fain, Jeremy Geelan, Maureen O'Gara, Nancy Y. Nee, Tad Anderson

Related Topics: ColdFusion, Adobe Flex

ColdFusion: Article

Poor Man's HTTP Compression with ColdFusion

Speed up your Website and lower bandwidth utilization

There are a couple of things to note before we begin.

First, HTTP Compression is a great way to speed up your Website and lower bandwidth utilization all at the same time. In this example, your ColdFusion server (6.1 and above) will encode CFML output using GZIP and have the browser decompress this data on the fly. In a corporate environment, Webmasters may choose to go with third-party software such as Port80 Software's httpZip, which can compress other files as well, including .js, .css, and your HTML files. In this example, we are only compressing the generated HTML output from a .cfm template execution.

Doing a Google search will reveal many different Java servlet filters that can do the job for you for free. Many of them have issues with memory leaks, don't scale well, or have other issues related to them, so make sure you are picking one that has been well tested, and make sure to always test any server changes in a development environment before deploying to production. Another thing to note is that not all browsers support GZIP encoding, so make sure your user group is using Microsoft Internet Explorer 6+ and Firefox 1.0+.

As a side note, if you are using ColdFusion to consume data from another ColdFusion server that is using HTTP Compression, be sure to read Steven Erat's blog post on potential issues and workarounds at www.talkingtree.com/blog/index.cfm/2004/7/28/20040729. A couple of CFHTTPParam tags allow you to tell the server to send an uncompressed response. In this example, we will be using Coldbeans Software's Compress Filter, which is available at www.servletsuite.com/servlets/gzipflt.htm.

  • Step 1
    Shut down ColdFusion.

  • Step 2
    In cfroot\wwwroot\WEB-INF\lib, download the gzipflt.jar file.

    In cfroot\wwwroot\WEB-INF, edit the web.xml file and place the following XML markup near the end of the file just before the closing </web-app> element:

    <!-- start GZipFilter settings -->
    <filter>
    <filter-name>GzipFilter</filter-name>
    <filter-class>com.cj.gzipflt.GzipFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>GzipFilter</filter-name>
    <url-pattern>*.cfm</url-pattern>
    </filter-mapping>

  • Step 3
    Restart ColdFusion.

    That's it!

    The effects of the changes can be measured quite easily in Firefox using the Web Developers Extension version 1.1.3. This extension is available at http://chrispederick.com/work/webdeveloper/.

    Load the ColdFusion Administrator Login page. On the Web Developer Extension, if you click Information -> View Response Headers, you should see something similar to this:

    Server: Microsoft-IIS/6.0
    Content-Type: text/html; charset=UTF-8
    Content-Encoding: gzip
    Content-Length: 2261

    200 OK

    Note, Content-Encoding and Content-Length, both of which indicate that the GZIP filter is running successfully. Go back to the ColdFusion Administrator Login page and, on the Web Developer Extension, if you click Information -> View Document Size, you should see something similar to Figure 1.

    In the "Documents" line, note that it compressed the ColdFusion Administrator Login page to one-fourth its original size, giving you a total savings of 6 kb. This may not seem like a lot, but try the same thing after logging in. You should see something similar to Figure 2.

    This page shows a savings of almost 40 kb! Now that's huge. Bring up other Websites on this server and watch the savings add up!

    I'd like to thank Steven Erat for reviewing this article prior to publication.

  • More Stories By Sami Hoda

    Sami Hoda is an 11-year IT and Web development veteran with degrees in Computer Information Systems and Management & Human Resources. You'll find him reading profusely and passionate about best practices.

    Comments (12) View Comments

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    Most Recent Comments
    vconfused 10/28/09 12:16:19 AM EDT

    Like several other comments here I am getting the "500 There is no web application configured to service your request error". I dug into the server logs and found that it is because of a "Unsupported major.minor version" error. Can you update Java safely (using ColdFusion 6.1) or is it not worth it?

    robmac 10/13/09 08:28:00 PM EDT

    I integrated the same in my application. I downloaded the gzipflt.jar, saved it at the required position and modified In cfroot\wwwroot\WEB-INF\web.xml. But when i restarted cf application server.I got "500 There is no web application configured to service your request" when tried to access my site. When reverted all the the thing, started working. I am using cf7.
    any ideas?

    robmac 10/12/09 01:03:00 AM EDT

    I am getting the same error as subhankar. Any ideas?

    justin.dunham 10/09/09 02:13:00 PM EDT

    I ran across an odd problem and wanted to see if anyone had any experience with it.
    I use the filter above and it works great, cuts down page sizes as expected.

    I am doing a zip download using cfcontent and it won't work in IE for some reason the file always said it was corrupt, works fine in FireFox, Opera, etc.
    After some investigation the IE version of the download wasn't getting the gzip decoded by the browser. I can use a cflocation to get to the zip after it's created, but this means I can't secure the files which isn't good for me. Is there a way to not apply the gzip filter on a script level basis? Or perhaps trick it into thinking the browser does not accept gzip encoding?

    Any thoughts would be appreciated.

    subhankar 08/17/09 06:25:00 AM EDT

    I integrated the same in my application. I downloaded the gzipflt.jar, kept it at the required position and modified In cfroot\wwwroot\WEB-INF\web.xml. But when i restarted cf application server.I got "500 There is no web application configured to service your request" when tried to access my site. When reverted all the the thing, started working. I am using cf7.
    Can you suggest where i am going wrong?

    Cita 11/01/07 01:35:39 PM EDT

    Hi,

    I tested my website with and without GZIP but speed is pretty much the same. I just followed the instructions here. I'm using CF7 and IE7.

    Thanks,
    Cita

    ??????? 08/16/07 12:01:17 AM EDT

    nice

    Ismael 06/04/07 07:25:16 AM EDT

    Hi,

    First of all, I would like to thank you for such a great article. The gzipftl.jar worked wonder for us. The only
    problem I had is when this is paired with trimflt.jar(to trim whitespace).

    Do you know if there's a workaround?

    Thank you.
    Ismael

    Michael Long 03/28/07 07:29:57 PM EDT

    Be nice to have listed the tradeoffs and provided some benchmarks. Yes, the resulting file size is smaller, but since the per-page processing overhead is higher, what's the net effect? Is the site faster, slower, or pretty much the same? Or is the sole reason for doing this simply to cut down on your bandwidth bill?

    Amnon 03/28/07 06:15:15 PM EDT

    Hi Sami,

    Thanks for the article. Do u have any suggestions on how I could do exactly the same for Flex remote object calls against cfcs using amf?

    Cheers,

    Amnon

    Joost van der Drift 03/19/07 09:18:21 AM EDT

    Hi,
    it seems that Gzip scrambles special characters. E.g. a single quote becomes a question mark, just like ë.
    How can that be solved? Is that because the code really has an ë instead of &eacut;?

    Sam Curren 03/17/07 01:39:34 AM EDT

    Is there some reason to use this over built in web server compression? IIS and Apache can both be configured to compress both static files and dynamically generated pages. With this method, only dynamic content is compressed....

    @ThingsExpo Stories
    Announcing Poland #DigitalTransformation Pavilion
    Digital Transformation is much more than a buzzword. The radical shift to digital mechanisms for almost every process is evident across all industries and verticals. This is often especially true in financial services, where the legacy environment is many times unable to keep up with the rapidly shifting demands of the consumer. The constant pressure to provide complete, omnichannel delivery of customer-facing solutions to meet both regulatory and customer demands is putting enormous pressure on...
    DXWorldEXPO LLC announced today that All in Mobile, a mobile app development company from Poland, will exhibit at the 22nd International CloudEXPO | DXWorldEXPO. All In Mobile is a mobile app development company from Poland. Since 2014, they maintain passion for developing mobile applications for enterprises and startups worldwide.
    CloudEXPO | DXWorldEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
    The best way to leverage your CloudEXPO | DXWorldEXPO presence as a sponsor and exhibitor is to plan your news announcements around our events. The press covering CloudEXPO | DXWorldEXPO will have access to these releases and will amplify your news announcements. More than two dozen Cloud companies either set deals at our shows or have announced their mergers and acquisitions at CloudEXPO. Product announcements during our show provide your company with the most reach through our targeted audienc...
    @DevOpsSummit at Cloud Expo, taking place November 12-13 in New York City, NY, is co-located with 22nd international CloudEXPO | first international DXWorldEXPO and will feature technical sessions from a rock star conference faculty and the leading industry players in the world.
    Everything run by electricity will eventually be connected to the Internet. Get ahead of the Internet of Things revolution. In his session at @ThingsExpo, Akvelon expert and IoT industry leader Sergey Grebnov provided an educational dive into the world of managing your home, workplace and all the devices they contain with the power of machine-based AI and intelligent Bot services for a completely streamlined experience.
    DXWorldEXPO | CloudEXPO are the world's most influential, independent events where Cloud Computing was coined and where technology buyers and vendors meet to experience and discuss the big picture of Digital Transformation and all of the strategies, tactics, and tools they need to realize their goals. Sponsors of DXWorldEXPO | CloudEXPO benefit from unmatched branding, profile building and lead generation opportunities.
    22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
    In his keynote at 19th Cloud Expo, Sheng Liang, co-founder and CEO of Rancher Labs, discussed the technological advances and new business opportunities created by the rapid adoption of containers. With the success of Amazon Web Services (AWS) and various open source technologies used to build private clouds, cloud computing has become an essential component of IT strategy. However, users continue to face challenges in implementing clouds, as older technologies evolve and newer ones like Docker c...
    "MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
    JETRO showcased Japan Digital Transformation Pavilion at SYS-CON's 21st International Cloud Expo® at the Santa Clara Convention Center in Santa Clara, CA. The Japan External Trade Organization (JETRO) is a non-profit organization that provides business support services to companies expanding to Japan. With the support of JETRO's dedicated staff, clients can incorporate their business; receive visa, immigration, and HR support; find dedicated office space; identify local government subsidies; get...
    Dion Hinchcliffe is an internationally recognized digital expert, bestselling book author, frequent keynote speaker, analyst, futurist, and transformation expert based in Washington, DC. He is currently Chief Strategy Officer at the industry-leading digital strategy and online community solutions firm, 7Summits.
    Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
    In past @ThingsExpo presentations, Joseph di Paolantonio has explored how various Internet of Things (IoT) and data management and analytics (DMA) solution spaces will come together as sensor analytics ecosystems. This year, in his session at @ThingsExpo, Joseph di Paolantonio from DataArchon, added the numerous Transportation areas, from autonomous vehicles to “Uber for containers.” While IoT data in any one area of Transportation will have a huge impact in that area, combining sensor analytic...
    Bill Schmarzo, author of "Big Data: Understanding How Data Powers Big Business" and "Big Data MBA: Driving Business Strategies with Data Science," is responsible for setting the strategy and defining the Big Data service offerings and capabilities for EMC Global Services Big Data Practice. As the CTO for the Big Data Practice, he is responsible for working with organizations to help them identify where and how to start their big data journeys. He's written several white papers, is an avid blogge...
    Charles Araujo is an industry analyst, internationally recognized authority on the Digital Enterprise and author of The Quantum Age of IT: Why Everything You Know About IT is About to Change. As Principal Analyst with Intellyx, he writes, speaks and advises organizations on how to navigate through this time of disruption. He is also the founder of The Institute for Digital Transformation and a sought after keynote speaker. He has been a regular contributor to both InformationWeek and CIO Insight...
    Michael Maximilien, better known as max or Dr. Max, is a computer scientist with IBM. At IBM Research Triangle Park, he was a principal engineer for the worldwide industry point-of-sale standard: JavaPOS. At IBM Research, some highlights include pioneering research on semantic Web services, mashups, and cloud computing, and platform-as-a-service. He joined the IBM Cloud Labs in 2014 and works closely with Pivotal Inc., to help make the Cloud Found the best PaaS.
    It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
    I think DevOps is now a rambunctious teenager - it's starting to get a mind of its own, wanting to get its own things but it still needs some adult supervision," explained Thomas Hooker, VP of marketing at CollabNet, in this SYS-CON.tv interview at DevOps Summit at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.