views:

149

answers:

1

I would like to gzip the html sources of my webpages, what's the best way to do it on a lighttpd/php5 server.

I have tried to do it by editing my php.ini file with:

zlib.output_compression = On
zlib.output_handler = On

but it seems to be a transparent compression only.

+2  A: 

You'll need to enable mod_compress on lighthttpd in addition to the changes you made in your php file.

http://www.cyberciti.biz/tips/lighttpd-mod%5Fcompress-gzip-compression-tutorial.html

Edit:

I believe you're looking for an html minimizer then. If you check out the headers that google is sending back they look like this:

(Status-Line)   HTTP/1.1 200 OK
Date    Thu, 22 Oct 2009 18:28:47 GMT
Expires -1
Cache-Control   private, max-age=0
Content-Type    text/html; charset=UTF-8
Content-Encoding    gzip
Server  gws
Content-Length  3519
X-XSS-Protection    0

The "Content-Encoding gzip" is what you're looking for if you want to check for to see if your webserver is properly compressing your files.

Nathan
I have done this now but It's doesn't compress the actual html source of my files. Have a look at google.com source, thats what I want to do.
mnml
When you view source, your html will not look like it's compressed. It is compressed over the transmission and decompressed when it arrives at your browser.
Nathan
Thanks for the answers I'll try to look around how I can minimize the html source with php.
mnml
Nathan
I found this script that could probably do what I was looking for but it seems that the project isn't maintained anymore: http://www.hotscripts.com/listing/php-code-sweeper/
mnml