Search code examples
apachemodulemod-deflate

Custom modules for the Apache HTTP server: what's the behavior of mod_deflate?


I wrote a custom module for the apache http server as described in: http://httpd.apache.org/docs/2.4/developer/modguide.html

ap_rprintf(r, "Hello, world!");

I've been asked about the behavior of mod_deflate http://httpd.apache.org/docs/2.2/mod/mod_deflate.html .

Will response to the client produced by my module will be compressed by mod_deflate if the client accepts the compression with Accept-Encoding: gzip ?

If my response is already gzipped , can I prevent mod_deflate to work ?

Do you have any reference/link about this ?

Thanks.


Solution

  • By default, it would be compressed if it met the normal conditions. You can opt out a few ways (below in rough order of intrusiveness):

    • set the no-gzip per-request environment variable (r->subprocess_env)
    • remove the mod_deflate output filter (mod_proxy_wstunnel.c has an example of moving a filter)
    • unset the accept-encoding header before writing your response
    • set a Content-Encoding: gzip response header

    The only reference is mod_deflate.c + output filter basics.