views:

124

answers:

2

I have a tomcat server configured (by mod_jk) to work through Apache Httpd server.

Apache Httpd server compresses (by mod_deflate) all text/html sent to browser.

Some jsp pages are interactive and long running, i.e. display progress or log during execution. If compression turned on, all text on these pages comes at the end of page execution.

I would like to have ability to set in JSP page some response header, e.g.

<% response.setHeader("X-Compress", "0"); %>

And in Apache Httpd this must result in disabling compression, for example by setting no-gzip environment variable.

Maybe there is other approaches?

A: 

I don't think it is possible via HTTP header, for this header is only used for telling the client how to behave. You however have to tell apache.

But can disable it using a .htaccess file, if that is an option:

RewriteRule . - [E=no-gzip:1]
JochenJung
.htaccess file can not be used inside web-application on Tomcat
huksley
A: 

Tested on recent setup (Apache httpd 2.2.16, Tomcat 6.0.29, mod_jk 1.2.30, tcnative-1.dll). There is no such problem (it may still exists using Apache httpd 2.0.x).

When using response.flushBuffer() or out.flush() in jsp, flush packet is sent to Apache via mod_jk. This in turn creates APR flush bucket which is received by deflate module and forces it to flush compression buffer to browser.

So response is COMPRESSED AND INTERACTIVE.

P.S. However, I`have created relevant patch which reacts on X-nogzip header from application server. Set to X-nogzip: 1 to disable compression.

http://huksley.sdot.ru/wp-content/uploads/2010/09/mod_jk-1.2.30-x-nogzip-patch.zip

huksley