Last Updated: February 25, 2016
·
465
· miguelperez

Caching assets in rails

Be sure to do this:

  1. Add the cache-digests gem if rails < 4

  2. Use the gem rack-zippy or heroku-rails-deflater so the application knows how to serve gziped assets.

  3. Add the assets to the config.assets.precompile array when including js or css in your views like:

    = javascript_include_tag "modernizr"
    = stylesheet_link_tag  "application"
  4. Do not include the files with the relative path like:

    = javascript_include_tag "/assets/v2/modernizr.js"

    Otherwise those files will not be updated after assets pre-compiling.