views:

115

answers:

1

I'm keen to get started experimenting with gzip, but like i used to find php.net when i first started learning php, the apache documentation confuses me a bit. http://httpd.apache.org/docs/2.0/mod/mod_deflate.html

I'd really appreciate a sample htaccess file to have a look at if anyone's got one?

Also are there things which should be changed in the httpd.conffile instead of htaccess if I'm enabling gzipping server-wide?

Sorry i'm a newb with apache!


edit:

so i enable mod_deflate in the httpd.conf and then putting the following into an ht access file will work (as an example)?

<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
</Location>
A: 

You can enable gzip either in Apache, with mod_deflate or with PHP. The module itself must be activated in Apache's main config file, though you can decide which files are compressed on a per-directory basis using .htaccess files (unless the main configuration forbids with AllowOverride None or similar). The link you included provides examples.

You can also enable it only in PHP by adding zlib.output_compression = On to your php.ini file.

Artefacto
thanks artefacto, i've updated my question, hopefully makes more sense!
Haroldo
is apache's main config file the httpd.conf file?
Haroldo
@Harol Yes it's the httpd.conf. And <Location> belongs in it, not in an .htaccess.
Artefacto
thanks for your help artefacto
Haroldo