PageSpeed Insights not seeing the Gzip compression

前端 未结 6 651
轮回少年
轮回少年 2021-02-05 11:01

I\'m trying to speed up my website. Google insights (https://developers.google.com/speed/pagespeed/insights) tells me that a critical problem is to enable GZip compression.

6条回答
  •  忘掉有多难
    2021-02-05 11:52

    There are three ways to enable gzip compression - By configuring server settings

    For apache -

    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    

    For nginx

    gzip on;
    gzip_comp_level 2;
    gzip_http_version 1.0;
    gzip_proxied any;
    gzip_min_length 1100;
    gzip_buffers 16 8k;
    gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
    gzip_disable "MSIE [1-6].(?!.*SV1)";
    gzip_vary on;
    

    And by editing .htaccess as shown above

    
    
    SetOutputFilter DEFLATE
    
    
    

    Source: Enable compression

提交回复
热议问题