Frage

I just hooked Amazon's CLoudfront CDN up to our app.

In the staging and production.rb file, in rails all it took was:

  config.action_controller.asset_host = Proc.new { |source, request|
    if request.ssl?
      "https://cfIDhere.cloudfront.net"
    else
      # Pick a random CDN
      "http://cdn0#{source.hash % 4}.mysite.com"  
    end
  }

The challenge now is that both production and staging envs both call this:

http://cdn02.mysite.com/assets/application.js

That's going to create so crazy issues. What's the best way to handle making the CDN work for both Prod and Staging?

I'd love to be able to do something like this:

http://cdn02.mysite.com/assets/production/application.js
http://cdn02.mysite.com/assets/staging/application.js

Anyone have any experience with this? Thanks

Keine korrekte Lösung

Andere Tipps

I would segregate your CDNs by environment. So CDN{\d\d} would be production, then app-stage-cdn{\d\d} would be staging.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top