我在想带有 :cache 选项的 javascript_include_tag 会自动 g-zip 合并的 javascript 文件:
<%= javascript_include_tag 'j1.js', 'j2.js', 'j3.js', :cache => 'js_all' %>
但它只是生成一个文件,该文件简单地将所有这些 javascript 文件合并为纯文本 mod;
那么如何自动g-zip合并后的文件呢?
'javascript_include_tag' 中是否有内置选项?
或者,
你如何解决 g-zip 问题?
手工?
编写执行系统“gzip”命令的 ruby 代码?
...
会对它做什么?
我使用nginx作为服务器;
最佳答案
我同意 Toby 的观点,通常配置您的网络服务器以对适用文件执行 gzip 压缩。
对于 Apache,请查看 mod_deflate
这是典型的 Apache 配置摘录
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml application/rss+xml application/json text/css text/javascript application/javascript application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
关于javascript - 在 rails 中,如何 g-zip 由 'javascript_include_tag' 生成的组合 javascript 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3580568/