Grigor Nazaryan
Grigor Nazaryan

Reputation: 577

Apache DEFLATE configuration

I have VirtualHost definition in my Apache config file. In this definition I have implemented SetOutputFilter DEFLATE. My problem is that I need to exclude files from deflate which have size smaller then 10k. When I try to use SetEnvIf Content-Length "^[0-9][0-9]?[0-9]?[0-9]?$" no-gzip function it doesnt work. Because of Content-Length of my request is exemined instade of response

Upvotes: 3

Views: 1091

Answers (1)

Light Harut
Light Harut

Reputation: 42

It is possible to set some specific header in your request. Based on this header apache can decide to compress your page or not.

LoadModule deflate_module                 /modules/mod_deflate.so
LoadModule headers_module                 /modules/mod_headers.so

<IfModule mod_deflate.c>
    <IfModule mod_setenvif.c>
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    </IfModule>
    <IfModule mod_headers.c>
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
    SetEnvIf DoCompress "^true" no-gzip dont-vary
    AddOutputFilterByType DEFLATE text/css application/x-javascript text/html
</IfModule>

Upvotes: 2

Related Questions