Forum OpenACS Q&A: Re: How to enable gzip compression

Collapse
Posted by Tom Jackson on

In AOLserver 4.5, you have to load the nszlib module:

ns_section ns/server/${server}/modules
ns_param nszlib "$Home/bin/nszlib.so"

The other params look good, but there is one additional one:

ns_section ns/server/${server}
ns_param gzip on     ; # default = on
ns_param gzipmin 4096; # default = 4*1024
ns_param gziplevel 3 ; # default = 4
Collapse
Posted by Héctor Romojaro on
Thanks Tom, the module is loading correctly now.

I've tested the example included with the nszlib module (example.tcl) and it works perfectly, but aolserver isn't returning gzipped pages yet, as I saw in the output headers and in http://www.whatsmyip.org/mod_gzip_test/.

Do i have to change anything in my openacs/dotlrn configuration to enable this?

Collapse
Posted by Tom Jackson on
You could help everyone out if you could explain how you test to see that it is or isn't working. I don't know how reliable it is to use the web page you reference to do the checking. It would be a real service to everyone to have a method to ensure that compression is working, when and where.

Maybe we need some kind of debug statement in the code to let developers know what the outgoing format is. This would include compression, encoding, caching, etc. There is a lot of information maintained in ns_conn.

Anyone have any experience with tracking what finally gets sent to the client?

Collapse
Posted by Héctor Romojaro on
Gzipped pages, as shown on rfc should have the following output header:

Content-Encoding: gzip

There is a list of the Browser and Output Headers in developer support pages, so i just expected to see that header there.
There is also a firefox extension to check the headers too.

I've tested the pages with external checks too, like the one I posted before (there are a lot of them) and checked the size of the page with the module nszlib enabled and disabled, but, to be really really sure if it is compressing or not, i did a tcpdump to the net interface of the client:

$ tcpdump -A src $URL -s 3000 > /tmp/dump

Examining the /tmp/dump file, I could see clearly the html plain code, so aolserver it's surely not compressing.

Anybody is using successfully gzip compression with aolserver 4.5 + openacs/dotlrn? Any tips?

Collapse
Posted by Tom Jackson on
Thanks for the link to the firefox plugin.

I have visited several websites, the browser is sending the gzip/deflate header, but nobody returns compressed content. Do you have any links to sites which do that?

Yes, www.mozilla.org is doing it, for example:

----------------------------------
http://www.mozilla.org/

GET / HTTP/1.1

Host: www.mozilla.org

User-Agent: Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.8.1) Gecko/20061010 Firefox/2.0

Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Accept-Language: es-es,es;q=0.8,en-us;q=0.5,en;q=0.3

Accept-Encoding: gzip,deflate

Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

Keep-Alive: 300

Connection: keep-alive

HTTP/1.x 200 OK

Age: 449

Date: Mon, 29 Oct 2007 19:25:01 GMT

Expires: Mon, 29 Oct 2007 19:35:01 GMT

Cache-Control: max-age=600

Connection: Keep-Alive

Via: NS-CACHE-6.1: 1

Etag: "2b5a-cc8b36c0"

Server: Apache/2.0.52 (Red Hat)

Last-Modified: Thu, 25 Oct 2007 20:08:35 GMT

Accept-Ranges: bytes

Content-Type: text/html

Content-Encoding: gzip

Content-Length: 3068

----------------------------------

That's the data from the headers given by the firefox plugin.

Hello Hector,

I would like to ask if you were successful with enabling gzip compression on your server.

I've been playing with nszlib in the past couple of days and like you I have been unable to get aolserver 4.5 to server gzip content.

However, I found that if I remove 0-acs-init.tcl and zz-postload.tcl from openacs/tcl/ aolserver ns_zlib works.

I'm guessing that it must be something in acs-init that is overriding ns_zlib.

I'm trying to trace acs-init now with the hopes of pin pointing exactly what is preventing compressed content and I was wondering if you have had any luck.

Thanks,

Hamilton

Hello Hamilton,

No, I couldn't, but i did a workaround using nginx to serve the pages in top of aolserver, as seen in malte's tutorial.

Now, nginx is doing gzip compression, ssl negotiation and serving static content (css, js, images...).

BTW, aolserver without ssl didn't restart with signal 11 errors anymore.

Greetings, Héctor