In our CMS there are several kinds of assets. As we build themes we will beautify them with varied JavaScript, CSS, and images. In order to keep the speed of our sites fast in the frontend, we will use asset caching in Rails.
The steps to follow will be to cache the content and speed up our site, as follows:
We will first make sure we have the right asset-related gems in
Gemfile
:gem 'sass-rails', '~> 4.0.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.0.0'
This will enable all kinds of assets and make it ready for production.
We will first enable asset compression inside our
production.rb
file:config/environments/production.rb. config.assets.compress = true
We will continue to edit the same file:
config.assets.compress = true # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier config.assets.css_compressor = :sass
We will now fix the
asset
folder totmp/cache/assets
:config/environments/production.rb config.assets.cache...