Cloud-based dynamic content - can I put API (JSON) results from Rails?

I see that the cloud interface supports dynamic content.

Can anyone explain how I can do this in Rails. For example, I have api.test.com/popular.json, which I would like to receive from the cloud cloud, preferably, but probably updated every few hours.

For static assets, I was able to do this using the Rails asset_host setting. But I could not find enough guidelines for dynamic content. Any pointers would be helpful.

+4
source share
1 answer

You do not need to integrate the rails application with CloudFront. Instead, you can configure CloudFront to cache your website:

  • Go to AWS Console and add a new CloudFront distribution
    • web delivery method
    • origin domain name : myexistingdomain.com

You can leave all the defaults as they are. The Minimum / Default / Maximum TTL parameter can be set to force the use of a specific cache time and may be required depending on your server settings.

  1. at myexistingdomain.com , you must set the Access-Control-Allow-Origin header to include the domain name of your Cloudfront distribution.

As you've probably already experienced, most updates to CloudFront or adding a source usually take ~ 20 minutes, so be patient.

In addition, if you need to use request parameters, cookies or special headers in your rails application, you will need to include them in the cache settings in your CloudFront distribution. Please note that this will decrease distribution efficiency.

0
source

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


All Articles