public class CompressionFilter extends BaseFilter
This filter requires isomorphic_compression.jar to be present in your WEB-INF/lib to work properly.
Please contact Isomorphic (http://forums.smartclient.com) to learn more about the Network Performance package.
Modifier and Type | Field and Description |
---|---|
java.util.List | compressableMimeTypes Comma separated list of mime types that are compressable. |
int | compressThreshold Minimum size of the dynamically captured buffer (in bytes) for compression to kick in. |
Modifier and Type | Method and Description |
---|---|
boolean | canCompressContext(RequestContext context) Is a specific request context compressable? Default implementation will disallow compression for messaging requests (determined by looking at the target request path). |
public int compressThreshold
Default is 250 Bytes.
public java.util.List compressableMimeTypes
The CompressionFilter asks the container for the mimeType of the intercepted URL before bufferring. If the mimeType is known at that time and does not match this list of mimeTypes, the CompressionFilter avoids bufferring the response.
If the mimeType is unknown, the CompressionFilter buffers the response in the hope that the upstream servlet/filter will set the mimeType. If the mimeType is still unknown or does not match this list of mimeTypes, the response will not be compressed.
For optimal performance, you should ensure that the CompressionFilter only buffers responses that it can compress. You can do this by:
Note that if you wish to add extensions to the default list, you should test them against your target browser platforms to ensure that the compression will actually work for that mimeType.
Also, make sure that what you specify here matches what your container returns as the mimeType for the extensions you intend to compress. For example, if your container is configured to return text/javascript
for *.js
files and you list only text/ecmascript
here then compression will be disabled for *.js
files.
The comparison is a substring match of the specified mimeType against what the container/response returns. So, for example, if you specified text/javascript
here and a JSP that was intercepted by the CompressionFilter set the mimeType via the @page contentType
directive to text/javascript; charset=UTF-8, then the match would be successfull because the latter string contains the former. If you don't specify this parameter on the filter definition or specify it with an empty value, the CompressionFilter will use the following default: text/html, text/xml, application/x-javascript, text/javascript, text/ecmascript, image/svg+xml, application/javascript
public boolean canCompressContext(RequestContext context)