aspose file tools*
The moose likes Performance and the fly likes How to comprese HTTP response Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "How to comprese HTTP response" Watch "How to comprese HTTP response" New topic
Author

How to comprese HTTP response

mohit mehta
Greenhorn

Joined: Sep 07, 2004
Posts: 7
Hi

I am working on one Struts-AJAX combination based project.
Where we are loading many text/xml on client machine in response.
Now due to this Web application has became very slow.
One way we found is to compress HTTP response and i found few example on that, like using Compressionfilter to wrap response in Gzip stream[refe tomcat examples for CompressionFilter implementation]
Now I have implemented that in our application and application is running without any problem also.
But i want to test about how much data compression is taken place in this?

Can anyone tell me how to about this?

How can i get datacompression rate?

Please suggest me some idea.

It will be great help if reply as soon as possible.

Regards,
Mohit
Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
There are a few different ways to measure this:

1. You could modify the compression filter to record the compression ratio. (Assuming you have access to the filter source code.)

2. You could create two filters -- one for either side of your compression filter to record the output stream lengths before and after the compression.

3. But I think the simplest solution (and the least impacting to performance) would be to write an applet or a servlet to request your compressed page twice. Once with the "accept-encoding: gzip" header and once without. Then compare the lengths of the two responses.
Scott Johnson
Ranch Hand

Joined: Aug 24, 2005
Posts: 518
The book Servlets and JSP: the J2EE Web Tier has a servlet that implements #3 above. You can download the source here:

http://www.jspbook.com/code.jsp

Look for the class com.jspbook.CompressionTest.
[ March 22, 2006: Message edited by: Scott Johnson ]
mohit mehta
Greenhorn

Joined: Sep 07, 2004
Posts: 7
Hi
Thanx a ton Scott.
finally I am able to test my application compression ratio.
even today i found one more example in tomcat example servlet where they are providing way to test compression.

in tomcat 5.0 inside servlets-examples folder you can get CompressionFilter and CompressionTest also.

Once again thank you very much for such great help.

Mohit.
Jason Moors
Ranch Hand

Joined: Dec 04, 2001
Posts: 188
I've used a web debugging tool called Charles (For some reason!), it's Shareware so you can evalute for free, I've found it really helpful in determining bandwidth.

Charles is an HTTP proxy / HTTP monitor that you to view all of the HTTP traffic between a client and the server. This includes requests, responses and the HTTP headers (which contain the cookies and caching information).

http://www.xk72.com/charles/

Jason.
[ March 24, 2006: Message edited by: Jason Moors ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to comprese HTTP response
 
Similar Threads
how Compress jsf response ?
Head First Session management : doubts
Very urg help me
how can i use google api in my intranet application
can anybody give me an example about this?