Rails how to Gzip Javascript? (Heroku)

混江龙づ霸主 提交于 2020-02-04 07:34:25

问题


I have run google page speed and it is saying that I should Gzip my javascript files?

How do I gzip my javascript files? My website is hosted on heroku if that mattter


回答1:


This answer is out of date but I can't delete it because it was accepted. So I'm turning it into a community wiki so that people can fix it up.


Heroku should be gzipping everything automatically (as long as the client supports it of course). From an old blog post:

All apps deployed to Heroku automatically compress pages they serve, by virtue of passing through Nginx’s gzip filter on the way out.

And from the current documentation:

On the heroku.com HTTP stack, requests enter the platform through Nginx, which handles SSL and Gzip.




回答2:


You can prezip your assets by using the jammit gem, running the jammit command before deploy, and uploading directly to heroku. Just make an config/assets.yml file, and then run "jammit"

http://documentcloud.github.com/jammit/




回答3:


As far as I understand it's web server's task to gzip files, I doubt you can modify heroku settings.

Besides, javascript files are usually cached by a browser, so normally it is not what you should be concerned about.



来源:https://stackoverflow.com/questions/6669553/rails-how-to-gzip-javascript-heroku

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!