2011-11-16 72 views
3

我在我的Apache配置文件中有VirtualHost定義。在這個定義中,我實現了SetOutputFilter DEFLATE。我的問題是我需要從尺寸小於10k的放氣中排除文件。 當我嘗試使用SetEnvIf Content-Length「^ [0-9] [0-9]?[0-9]?[0-9]?$」no-gzip函數時,它不起作用。由於我的請求的內容長度被排除在響應之外Apache DEFLATE配置

回答

2

可以在請求中設置一些特定的標頭。基於這個頭文件,Apache可以決定是否壓縮你的頁面。

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>