Skip to content

Instantly share code, notes, and snippets.

@JoeyGo23
Forked from francirp/gist:9fe05dcbcf4ffabbf0e1
Last active August 29, 2015 14:16
Show Gist options
  • Save JoeyGo23/f69f9927dd8428c4423c to your computer and use it in GitHub Desktop.
Save JoeyGo23/f69f9927dd8428c4423c to your computer and use it in GitHub Desktop.

Revisions

  1. @francirp francirp created this gist Feb 24, 2015.
    29 changes: 29 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    Cloudfront
    ---

    First, create a new Cloudfront distribution via Amazon AWS console. Once you've done that, it's as simple as adding the following to your production environment (and staging if you run a staging environment), replacing the value with your CDN host url:

    ```config.action_controller.asset_host = "<YOUR DISTRIBUTION SUBDOMAIN>.cloudfront.net"```

    See here for more info: https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn#adding-cloudfront-to-rails


    Gzip
    ---
    This boosts performance. Helpful post here: http://thediscoblog.com/blog/2013/05/01/the-rails-cloudfront-and-heroku-performance-hat-trick/

    To add gzip via Heroku Deflater gem:

    Gemfile.rb:
    ```ruby
    gem 'heroku-deflater', group: [:production, :staging]
    ```

    config/environments/production.rb and config/environments/staging.rb:
    ```ruby
    config.static_cache_control = 'public, max-age=31536000'
    config.middleware.delete "ActionDispatch::Static"
    config.middleware.insert_before(Rack::Runtime, ActionDispatch::Static, paths["public"].first, config.static_cache_control)
    ```

    You can see the result on our site: www.launchpadlab.com