apache2 mod_deflate不要压缩

时间:2018-06-27 12:08:15

标签: apache2 mod-deflate

我在通过apache2服务器上的mode_deflate启用压缩时遇到问题。我不知道为什么它不起作用:

模块已启用:

# apache2ctl -M
Loaded Modules:
 ...
 deflate_module (shared)
 expires_module (shared)
 filter_module (shared)
 mime_module (shared)
 ...

000-default.conf:

...
<Directory /var/www/>
    Options -Indexes +FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
...

.htaccess

# Deflate Compression by MimeType
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    AddOutputFilterByType DEFLATE application/x-font-woff
</IfModule>

# Deflate Compression by FileType
<IfModule mod_deflate.c>
    <FilesMatch "\.(js|jpg|jpeg|gif|png|svg|css|eot|ttf|woff)$">
        ExpiresActive on
        ExpiresDefault "access plus 1 month"
        SetOutputFilter DEFLATE
    </FilesMatch>
</IfModule>

# turns cache on for 1 month
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType text/javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType application/x-font-woff "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/svg+xml "access plus 1 month"
    ExpiresByType image/x-icon "access plus 1 month"
</IfModule>

<IfModule mod_headers.c>
    <filesmatch "\\.(ico|jpe?g|png|gif|svg|swf|eot|ttf|woff)$">
        Header set Cache-Control "max-age=2592000, public"
    </filesmatch>
    <filesmatch "\\.(css)$">
        Header set Cache-Control "max-age=604800, public"
    </filesmatch>
    <filesmatch "\\.(js)$">
        Header set Cache-Control "max-age=604800, public"
    </filesmatch>
</IfModule>

PageSpeed Insights说:svg,css,js和html文件的压缩不起作用吗? 有人可以帮忙吗?谢谢!

0 个答案:

没有答案