Search code examples
javaapachetomcatmod-jkmod-deflate

How to disable compression in Apache on some response header from mod_jk proxied application server


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?


Solution

  • 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