【问题标题】:Enabling compression (Amazon EC2)启用压缩 (Amazon EC2)
【发布时间】:2015-04-20 06:24:16
【问题描述】:

我正在尝试通过将以下内容添加到我的 .htaccess 中来对我的 EC2 实例启用压缩:

<IfModule mod_deflate.c>
# Force compression for mangled headers.
# http://developer.yahoo.com/blogs/ydn/posts/2010/12/pushing-beyond-gzipping
<IfModule mod_setenvif.c>
    <IfModule mod_headers.c>
        SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
        RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
    </IfModule>
</IfModule>

# Compress all output labeled with one of the following MIME-types
# (for Apache versions below 2.3.7, you don't need to enable `mod_filter`
#  and can remove the `<IfModule mod_filter.c>` and `</IfModule>` lines
#  as `AddOutputFilterByType` is still in the core directives).
<IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE application/atom+xml \
                                  application/javascript \
                                  application/json \
                                  application/ld+json \
                                  application/rss+xml \
                                  application/vnd.ms-fontobject \
                                  application/x-font-ttf \
                                  application/x-web-app-manifest+json \
                                  application/xhtml+xml \
                                  application/xml \
                                  font/opentype \
                                  image/svg+xml \
                                  image/x-icon \
                                  text/css \
                                  text/html \
                                  text/plain \
                                  text/x-component \
                                  text/xml
</IfModule>

我检查了我服务器的 httpd.conf 并且正在加载 mod_deflate

我正在运行 Apache 2.2.29

我还可以检查哪些内容不工作? :-/

【问题讨论】:

  • 能否让我知道您或其他人是否添加了这些,因为我没有默认加载任何模块?哦,我现在看到我的模块都加载到了 conf.modules.d

标签: apache .htaccess amazon-ec2 compression mod-deflate


【解决方案1】:

我需要启用mod_filter。现在一切正常!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-04-17
    • 2015-03-28
    • 2013-12-29
    • 2015-12-26
    • 1970-01-01
    • 1970-01-01
    • 2013-05-05
    相关资源
    最近更新 更多