Do I have to configure nginx to compress assets (gzip set to on) if I have compressed rails assets with rake assets:precompile
? I mean does it make sense or not? Will performance better or worse? Thank you!
相关问题
- Question marks after images and js/css files in ra
- Using :remote => true with hover event
- Eager-loading association count with Arel (Rails 3
- Is there a way to remove IDV Tags from an AIFF fil
- Rails how to handle error and exceptions in model
What worked for me was configuring Nginx:
Then in application.rb:
Here is a complete configuration(I am using it for my site):
GENERAL CONFIGURATION
Content of /opt/nginx/conf/nginx_host.conf;
HOST CONFIGURATION
For serving assets:
Do rake assets:precompile and you have to configure nginx for send gzip version of files, i use this configuration.
No, you do not. They are not the same kind of compression. When you run
rake assets:precompile
, all you're really doing is joining a bunch of files into one file and dumping it to the disk. Actually, according to the official documentation, it is two files:This is important for you, because it allows you to use gzip, if you want, but it does not force you to do so. Gzip compression, which is real compression (not just concatenating files) reduces the amount of data you have to transfer, but at the expense of processor power (compressing and decompressing). It is likely to fairly dramatically improve your site, depending on page sizes and your (and your user's) hardware.
Yes, you should if you want to improve performance.
Simply add the following block to your site configuration:
Change the root path in the configuration. That is all there is to it.
RecommendationFromDocumentation™: http://guides.rubyonrails.org/asset_pipeline.html