Enable HTTP Compression in lighttpd

Compression can save your valuable bandwidth & helps your site load faster on client’s end. However on the other end it takes little extra resources of your server.

1. Configure mod_compress

Open your lighttpd.conf file:

vim /etc/lighttpd/lighttpd.conf

Append mod_compress to server.modules directive:

server.modules += ( “mod_compress” )

Setup compress.cache-dir to stored all cached file:

compress.cache-dir = “/var/run/cache/lighttpd/compress”

Finally, define mimetypes to get compressed. Following will allow to compress javascript, plain text files, css file,xml file etc:

compress.filetype = (“text/plain”,”text/css”, “text/xml”, “text/javascript” )

Save and close the file.

2. Create /var/run/cache/lighttpd/compress/

mkdir -p /var/run/cache/lighttpd/compress

chown lighttpd:lighttpd /var/run/cache/lighttpd/compress

3. Restart lighttpd

Enjoy!!!

Leave a Reply

Your email address will not be published. Required fields are marked *