We have a conditional compression setup: if some pages are small, it is
better not to compress them as the time the browser takes to decompress
makes the site slower on aggregate, esp with netscape.
The settings to control whether we zip and the threshold at which to zip can
then be adjusted for the most responsive 'feel'
import java.util.zip.*;
.
.
ByteArrayOutputStream bytes;
. (put html into bytes)
.
String encodings = request.getHeader("Accept-Encoding");
if
(PropertyReader.getInstance().getBooleanProperty("Controller.properties",
"ZIP") &&
bytes.size() >
PropertyReader.getInstance().getIntProperty("Controller.properties",
"MIN_ZIP") &&
encodings!=null &&
encodings.indexOf("gzip") != -1
)
{
resource.log.debug("gzip");
response.setHeader("Content-Encoding","gzip");
OutputStream out = new
GZIPOutputStream(response.getOutputStream());
bytes.writeTo(out);
out.close();
}
else
{
resource.log.debug("no zip");
bytes.writeTo(response.getOutputStream());
}
Works well.
Al
-----Original Message-----
From: Torgeir Veimo [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 27, 2001 3:05 PM
To: [EMAIL PROTECTED]
Subject: Re: Compressing Tomcat output.
I think this can most easily be done by apache using a gzip module that
automatically compresses all responses if accepted by the client.
--
- Torgeir