Search code examples
perlapachemod-perlmod-deflate

Howto disable mod_deflate compression from within a mod_perl script


I'm developing a web application running on Apache that is generating content in Perl scripts (mod_perl) and the output is being compressed with mod_deflate.

This works pretty well, but sometimes during the content generation the script notices that this page will not compress well and the final compression step should better be skipped.

mod_deflate is enabled by content type in the Apache configuration. Is it possible that the script eg. sets a flag or environment variable etc. that compression is disabled ?


Solution

  • From the mod_deflate docs:

    "For browsers that have problems even with compression of all file types, use the BrowserMatch directive to set the no-gzip note for that particular browser so that no compression will be performed."

    Setting the 'no-gzip' environment var looks like it will do the trick.