如何在heroku上的PHP应用程序中启用压缩?

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了如何在heroku上的PHP应用程序中启用压缩?脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我在heroku应用程序的.htaccess文件中运行 HTML5 Boilerplate压缩.但是,它似乎没有工作,并且没有文件实际上被压缩.

添加了heroku PHP buildpack:

heroku config:set BUILDPACK_URL=https://gIThub.COM/heroku/heroku-buildpack-PHP

但那似乎没有做任何事情.我对Heroku很新,所以有人有什么建议吗?

HTML5 Boilerplate htaccess代码

# 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/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>
我发现使用不同的buildpack工作了!
heroku config:set BUILDPACK_URL=http://github.com/iphoting/heroku-buildpack-PHP-tyler

这是一个很棒的buildpack,支持gzip压缩并安装新文件.

脚本宝典总结

以上是脚本宝典为你收集整理的如何在heroku上的PHP应用程序中启用压缩?全部内容,希望文章能够帮你解决如何在heroku上的PHP应用程序中启用压缩?所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。