Question

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?

Was it helpful?

Solution 3

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

OTHER TIPS

I am using mod_layout to add a header to the page. It has issues when the page comes from tomcat through mod_jk. It adds the plain text header before the gzipped binary code, corrupting the gz file. It seems to have very poor documentation, but does a fine job other than the compression problem.

Unfortunately,

RewriteRule . - [E=no-gzip:1]

did not work for me.

Neither did:

AddOutputFilterByType DEFLATE text/html text/plain text/xml

This did work:

  1. enable mod_headers

  2. add a line to your VirtualHost

    RequestHeader unset Accept-Encoding

More about mod_headers: http://httpd.apache.org/docs/2.0/mod/mod_headers.html

My mod_layout came from Ubuntu's package manager, but it is also here: htt p://download.tangent.org/

And here is the page where I first read about mod_layout: http://www.linuxjournal.com/article/4334

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]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top