Using S3 / CloudFront with Rails 3 and Less CSS Resources

This is one sip! Basically, I'm trying to send all my Rails 3 resources to the S3 cloud and use CloudFront as a CDN to deliver all this. I already learned about configuring Rails to output assets from the server in production mode. The problem I am facing is finding a good way to automatically pack and send everything to the cloud from the rake or rails gem command. Another issue I have is that I don’t know if using Less CSS with Gem would be more to mess it up. More generates a CSS file from another directory and puts it in the public / style sheets. Any ideas or suggestions are greatly appreciated! Thank:)

+3
source share
1 answer

If you click on Heroku and use the assets of Rails 3.1, you are all set up.

In the CloudFront configuration on amazon, create your distribution and set the source to the URL of your application.

Then in the production.rb file add:

config.action_controller.asset_host = "xxxxxxxxx.cloudfront.net"

The host is the host of your CloudFront distribution.

Then, when deploying, make sure you are on the Cedar stack and these resources are compiled. This will add unique MD5 to the file names. When the request arrives on your CDN (it is automatically processed by the settings in the production.rb file), the CDN will either serve its version of the file, or first pull it from the source. This means that you do not need to push files to the CDN, they are automatically retracted.

, - , , CloudFront, .

+3

Source: https://habr.com/ru/post/1795556/


All Articles