How to send compressed (deflated) SVG via Apache2?

前端 未结 5 530
夕颜
夕颜 2020-12-04 21:49

I have specified the following attributes in my site\'s .htaccess file:

AddOutputFilterByType DEFLATE image/svg+xml
DeflateCompressionLevel 9
He         


        
5条回答
  •  遥遥无期
    2020-12-04 22:23

    Best option I found is to compress everything except images, which mod_deflate isn't able to handle it.

    add following lines to httpd.conf file:

    LoadModule deflate_module modules/mod_deflate.so
    
    SetOutputFilter DEFLATE
    
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    
    SetEnvIfNoCase Request_URI \
    
    \.(?:gif|jpe?g|png|exe)$ no-gzip dont-vary
    

    If u want to see logging of what was compressed add the following also:

    DeflateFilterNote Input instream
    
    DeflateFilterNote Output outstream
    
    DeflateFilterNote Ratio ratio
    
    LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
    
    CustomLog logs/deflate_log deflate
    

提交回复
热议问题