lighttpd plugins: mod_deflate for 1.4.13
Published October 18th, 2006 in TechLong Time No See! Recently I was busy with testing mod_cache, which was more sophicated than expected. Here I want to present guys with mod_deflate before mod_cache's annoncement.
mod_deflate is a lighttpd plugin to compress content on fly. It's useful when you want to reduce your bandwidth consumption to 30% or lower:) my patch is based on jakabosky's 1.4.11 patch and fixed several big bugs includes:
1) fix loop bug when content-length is bigger than work-block-size*k
2) prevent compress on buggy http 1.0 client with Accept Encoding: gzip, deflate
3) fix bug with chunk transfer encoding (for examples in mod_fastcgi+php environment)
mod_deflate don't compress uri matched deflate.nocompress-url which is a pcre regex string.
I had used mod_deflate in production environments and found no noticable bugs or memory leak. Usually mod_deflate takes less than 10% CPU and eats up less than 100M memory. Full document is here
Here I want to say big thanks to Jakabosky, his mod_deflate patch makes mod_cache on lighttpd possible.
connections.c: In function 'connection_handle_read_ssl':
connections.c:200: warning: unused parameter 'srv'
connections.c:200: warning: unused parameter 'con'
connections.c: In function 'connection_reset':
connections.c:810: error: 'connection' has no member named 'use_cache_file'
connections.c:811: error: 'connection' has no member named 'write_cache_file'
make[2]: *** [connections.o] Error 1
make[2]: Leaving directory `/var/tmp/lighttpd/lighttpd-1.4.13/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/tmp/lighttpd/lighttpd-1.4.13'
make: *** [all] Error 2
I got this error , after patched my lighttpd 1.4.13
any idea?
thanks
maybe it only works with mod_cache?
just delete
con->use_cache_file = 0;
con->write_cache_file = 0;
lines from connections.c
I will make cleaner patch later
patch updated!
I installed mod_deflate on lighty 1.4.13 then turned off php's zlib output. But my server replies blank content to all requests.
OS: FreeBSD 6.1.
same here.
OS: Linux, php 4.4.2
running mod_fastcgi mod_deflate on the same lighttpd?
sure, they are on same host
add
deflate.output-buffer-size = 8192
to your lighttpd.conf and see if it worked for you.
change this line
s->output_buffer_size = 0;
to
s->output_buffer_size = 32768;
and
set
deflate.sync-flush = "enable"
to
deflate.sync-flush = "disable"
in lighttpd.conf
it worked.
deflate.sync-flush is buggy. but I don't remove it because I never enable it.
Still buggy when compressing large content. Try:
This will crash IE/FF and Opera all.
how large is your content? bigger that deflate.work-block-size * k bytes? I test to compress about 8M content without any problem
About 550KB. deflate.work-block-size is 32.
我写了个简单PHP程序,输出一个512k大小内容,deflate.work-block-size=32, mod_deflate 表现正常,没有发现问题
Try a script that outputs numbers from 1 to 1,000,000 and test its consistency. I often received corrupted (broken) outputs. Sometimes mod_fastcgi sets file_finished to 1 too early, so mod_deflate ends up the entire reply body too early.
lighttpd-1.4.13.mod_deflate.patch
lighttpd-1.4.13.mod_cache.v1.2.patch
lighttpd-1.4.13.mod_deflate.patch
这2个patch 有冲突么?打了这个打不了另外一个