Glassfish 3 - gzip compression does not work for .jsp
Please watch this short video which show开发者_运维技巧s my problem in detail: http://youtu.be/uAza4m3fxpY?hd=1
I have a Glassfish 3.1 server running a Netbeans Web Project. I have a very simple .jsp file with content type set to 'text/html' and a large paragraph of dummy text in the body. It looks like this:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Gzip Test</title>
</head>
<body>
<h1>Gzip compsression test</h1>
<p>****LOTS OF DUMMY TEXT***</p>
</body>
</html>
In Glassfish admin, I have forced-enabled gzip compression for the HTTP listener (as described in this guide: http://www.vikasing.com/2010/01/enable-gzip-compression-on-glassfish-v3.html)
When load the page in Firefox and look at the response header, I would expect to see Content-Encoding: gzip
, but it's not there.
Why is the content not being Gzipped?
I've discovered that this is a bug in Glassfish 3.1. It does not property split the accept-encoding
header using the ,
character. For example, if you set firefox's accept-encoding
header to: gzip, deflate
it will not gzip the content because the comma screws it up, but if you set it to gzip
then it does get gzipped by the server because there is no comma to choke on. Apparently this has been fixed in Glassfish 3.1.1 but I have not tested it yet. See: http://www.java.net/forum/topic/glassfish/glassfish/gzip-compression-glassfish-3-doesnt-work?force=899 for more details.
Thanks for the video. I remember this came up before Glassfish 3.0 was released as a part of FishCAT.
I think the problem you are having is because you are only setting the one listener 'http-listener-1' and you need to set 'http-listener-2' as well. (perhaps you did this, but did not show it in the video ?)
The same bug in Glassfish 3.1.2 and even 4.0 Beta - it looks like gzip compression has become completely buggy. Even if accept-encoding of firefox is set to solely gzip it doesn't work. You might be using CompressionFilter from Google, but it is quitely difficult to use as it use a number of dependencies.
I've got the same issues with glassfish 3.1.2.2 and gzip.
Responses to HTTP requests in version 1.0 are not compressed. You must send your requests in HTTP 1.1 to get gzipped responses from your glassfish server.
More over, you must add the header "Accept-Encoding: gzip" in your http requests.
精彩评论