Compressing Content Using a Servlet Filter:
Compression is a process that reduces the number of bytes required to define a document in order to save disk space or transmission time. It is extremely useful for sending information across the web, because the speed at which people receive information from a web application is dependent upon how much data you are trying to send. The smaller the amount of information that is to be sent, the faster it can be sent. Therefore, compression and the associated responsiveness is a key component to retaining users and generating revenue from those retained users.
Compression can be effectively achieved by having a servlet filter conditionally pipe the produced content to a GZip-compressed file. GZip is supported by the HTTP protocol and almost all modern browsers (hence the servlet filter conditionally compresses the content).
GZip compression usually results in a 6:1 compression ratio, although this depends on how much content is being sent and what the content is.
Setting up the Servlet Filter in ColdFusion
Using the ColdBeans servlet filter found at the following URL:
http://www.servletsuite.com/servlets/gzipflt.htm
1.Download the GZipFilter.jar
2.Save GZipFilter.jar in the WEB-INF/lib folder in the ColdFusion Server wwwroot.
3.Edit the web.xml file in the WEB-INF folder in the ColdFusion Server wwwroot with the following code:
"<"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>
4.Restart the ColdFusion Service
Now, when you invoke any .cfm page the GzipFilter will check out client’s browser settings. If the browser does not support gzip, the filter invokes resource normally. If the browser does support gzip, output will be compressed.
Note: Link for more details http://www.simonwhatley.co.uk/poor-mans-http-compression-with-coldfusion
~Thanks
Mohan
Monday, February 2, 2009
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment