加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

ruby-on-rails – 压缩rails资产和nginx gzip

发布时间:2020-12-13 21:28:14 所属栏目:Nginx 来源:网络整理
导读:如果我用rake资源压缩了rails资产,我必须配置nginx来压缩资产(gzip设置为on):预编译?我的意思是没有意义吗?会表现好还是差?谢谢! 最佳答案 你不可以.他们不是一样的压缩.当您运行rake资产:预编译时,您正在做的所有事情是将一堆文件加入到一个文件中并

如果我用rake资源压缩了rails资产,我必须配置nginx来压缩资产(gzip设置为on):预编译?我的意思是没有意义吗?会表现好还是差?谢谢!

最佳答案
你不可以.他们不是一样的压缩.当您运行rake资产:预编译时,您正在做的所有事情是将一堆文件加入到一个文件中并将其转储到磁盘.其实根据official documentation,它是两个文件:

When files are precompiled,Sprockets also creates a gzipped (.gz)
version of your assets. Web servers are typically configured to use a
moderate compression ratio as a compromise,but since precompilation
happens once,Sprockets uses the maximum compression ratio,thus
reducing the size of the data transfer to the minimum. On the other
hand,web servers can be configured to serve compressed content
directly from disk,rather than deflating non-compressed files
themselves.

这对你很重要,因为它允许你使用gzip,如果你愿意,但它不强制你这样做. Gzip compression是真正的压缩(不仅仅是连接文件),可以减少传输数据量,而是牺牲处理器的功率(压缩和解压缩).根据页面大小和您的(和您的用户的)硬件,可能会显着提高您的网站.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读