美文网首页
httpd常用配置:使用mod_deflate模块压缩页面优化传

httpd常用配置:使用mod_deflate模块压缩页面优化传

作者: Simon_Ye | 来源:发表于2020-02-25 13:35 被阅读0次

    适用场景

    1. 节约带宽,额外消耗CPU;同时,可能有些较老浏览器不支持;
    2. 压缩适于压缩的资源,例如文本文件;

    设置过滤器

    vim /etc/httpd/conf.d/compress.conf

    SetOutputFilter DEFLATE    #名字可以自定义
    
    # mod_deflate configuration
    
    # Restrict compression to these MIME types
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE applicatioin/xml
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/css
    
    # Level of compression(Highest 9 - Lowest 1)
    DeflateCompressionLevel 9
    
    #Netscape 4.x has some problems.
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    
    #Netscape 4.06-4.08 have some more problems
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    
    #MSIE masquerades as Netscape but it is fine
    BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
    

    相关文章

      网友评论

          本文标题:httpd常用配置:使用mod_deflate模块压缩页面优化传

          本文链接:https://www.haomeiwen.com/subject/ldazqhtx.html