Feb 2004

provide gzip for my apache/php based blog?

(10:10 pm) Tags: [How do I...]

Since Alex and I are trying to be good netizens, and we want to spare the precious bandwidth, we implemented gzip support for most of our websites. Since we are using Apache and PHP with the great b2 rewrite that is WordPress, I want looking for documentation.

If you are using Apache 2.0, follow along, this is relatively painless. Reading the great documentation for Apache 2.0 mod_deflate, just add the recommended configuration to your httpd.conf and restart apache.

Add this to your httpd.conf
AddOutputFilterByType DEFLATE text/html text/plain text/xml
<Location />
    # Insert filter
    SetOutputFilter DEFLATE
    # Netscape 4.x has some problems…
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    # Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    # MSIE masquerades as Netscape, but it is fine
    # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
    # the above regex won’t work. You can use the following
    # workaround to get the desired effect:
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    # Don’t compress images
    SetEnvIfNoCase Request_URI \
    \.(?:gif|jpe?g|png)$ no-gzip dont-vary
    # Make sure proxies don’t deliver the wrong content
    Header append Vary User-Agent env=!dont-vary

See how easy this is when someone else did most of the work? :) Now we test it. Since Ted has done the legwork on this, all we need to do is ask Leknor if everything is good by navigating here to see if we are now gzipped.

Summary: It is not terribly hard to add gzip support to your blog entries (or your entire website), as long as you ask the web wizards for the magic incantations. YMMV.

Popularity: 8%

Comments: Comments Off

add gzip support into php 4?

(8:57 pm) Tags: [How do I...]
Comments: Comments Off