Rails 3 automatic asset deployment to Amazon CloudFront?

后端 未结 4 1032
礼貌的吻别
礼貌的吻别 2020-12-30 09:19

Is there a gem or method available in Rails 3.1 that can upload assets to amazon cloud front automatically and use those instead of serving locally hosted ones?

4条回答
  •  春和景丽
    2020-12-30 09:34

    Definitely check out asset_sync on github. Or our Heroku dev centre article on Using a CDN asset Host with Rails 3.1 on Heroku.

    There is quite a big performance improvement in using asset_sync vs a CDN custom origin, letting your application lazily compile assets in production or serving them precompiled directly off your app servers. However I would say that. I wrote it.

    • With asset_sync and S3 you can precompile assets meaning all the assets are there ready to be served on the asset host / CDN immediately
    • You can only require the :assets bundle in application.rb on precompile, saving memory in production
    • Your app servers are NEVER hit for asset requests. You can spend expensive compute time on, you know. Computing.
    • Best practice HTTP cache headers are all set by default
    • You can enable automatic gzip compression with one extra config

提交回复
热议问题