Compressing rails assets and nginx gzip
asset-pipeline, nginx, ruby-on-rails
Solution
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:
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.
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.
Problem
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!