Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Testing Apache for gzip modules



On Sat, Sep 25, 2010 at 20:15, Dave M G <dave@example.com> wrote:
TLUG,

I'm trying to set up my web sites to use gzip compression and expires
headers.

Naturally, I'm trying to learn from searching the web for instructions
on exactly how to do that.

I found code to add to my .htaccess file, but it doesn't seem to be
working, so I think maybe my host server doesn't have the right Apache
modules enabled.

I think I need modules called mod_gzip and mod_expires.

This is where I've hit a wall. I can't figure out what commands to issue
to confirm the presence or absence of the right modules.

I figure it should be easy, but I've come up with nothing.

Can someone point me in the right direction? To confirm the modules and
enable them if they're not present?

Any advice would be much appreciated.

First of all, what version of Apache are you using? Things have changed between the different releases and I strongly suggest you to go with 2.2.

If you are using 2.x and you have mime types configured it should be as easy as loading the module:

LoadModule deflate_module /...path...to.../mod_deflate.so

The deflate module is actually an output filter basically meaning that Apache will "transform" something on its output. But you need to configure the "what" output to transform (in our case, compress). Look at the various AddOutputFilterBy... directives.

You can add the filter by extension (see http://httpd.apache.org/docs/2.0/mod/mod_mime.html#addoutputfilter), for example this will compress all URIs ending in .html, .css, or .js:

AddOutputFilter DEFLATE html css js

But for example won't catch the home page of your site http://mysite.dom/ (as it doesn't end with one of those extensions). But you can add the same filter inspecting the mime type (see http://httpd.apache.org/docs/2.0/mod/core.html#addoutputfilterbytype) for example:

AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/_javascript_

Will do the same as above, but considering mime types rather than extensions. To verify that it's actually working, I use CURL as it's the easiest method:

# curl -D /dev/stderr -s --compressed http://127.0.0.1/ > /dev/null
HTTP/1.1 200 OK
Date: Sat, 25 Sep 2010 13:20:03 GMT
Server: Apache/2.2.14 (Ubuntu)
Last-Modified: Wed, 14 Apr 2010 12:36:12 GMT
ETag: "5eb09-61-484319f9066c4"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 77
Content-Type: text/html
#

If you see a header Content-Encoding: gzip in the response, bingo, you have a winner!

Hope this helps!

    Pier








 

Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links