lighttpd plugins: mod_deflate for 1.4.13

Long 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.

Download PATCH

Keywords: , , ,


18 Responses to “lighttpd plugins: mod_deflate for 1.4.13”  

  1. 1 zend

    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

  2. 2 zend

    maybe it only works with mod_cache?

  3. 3 Q

    just delete
    con->use_cache_file = 0;
    con->write_cache_file = 0;

    lines from connections.c

    I will make cleaner patch later ;)

  4. 4 Q

    patch updated!

  5. 5 namosys

    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.

  6. 6 zend

    same here.
    OS: Linux, php 4.4.2

  7. 7 Q

    running mod_fastcgi mod_deflate on the same lighttpd?

  8. 8 zend

    sure, they are on same host

  9. 9 Q

    add
    deflate.output-buffer-size = 8192
    to your lighttpd.conf and see if it worked for you.

  10. 10 zend

    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.

  11. 11 Q

    deflate.sync-flush is buggy. but I don't remove it because I never enable it.

  12. 12 namosys

    Still buggy when compressing large content. Try:

    This will crash IE/FF and Opera all.

  13. 13 Q

    how large is your content? bigger that deflate.work-block-size * k bytes? I test to compress about 8M content without any problem

  14. 14 namosys

    About 550KB. deflate.work-block-size is 32.

  15. 15 Q

    我写了个简单PHP程序,输出一个512k大小内容,deflate.work-block-size=32, mod_deflate 表现正常,没有发现问题

  16. 16 namosys

    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.

  17. 17 acfear

    lighttpd-1.4.13.mod_deflate.patch

  18. 18 acfear

    lighttpd-1.4.13.mod_cache.v1.2.patch
    lighttpd-1.4.13.mod_deflate.patch

    这2个patch 有冲突么?打了这个打不了另外一个

Leave a Reply



天气信息