We've moved discussions to Discord

ActiveStorage + CDN ? (recommended but we need further info)

safeMint
In the documentation it says:
"For production, we strongly recommend using a CDN for serving files. Active Storage processes images through Rails which can add unncessary load to your Rails application and slow down your app if you don't have a CDN in production."

Is there any more information on setting this up?  I didn't see any videos about setting up a CDN on gorails.com.

I found this thread on gorails.com: https://gorails.com/forum/how-can-i-setup-cloudfront-cdn-for-rails-app

But this was for rails 4 and before ActiveStorage (and webpacker).

Curious if there are any best practices today.
safeMint
thanks  Ohad Dahan but that only covers direct uploads from javascript.  nothing about once its uploaded, serving it from a cdn

any thoughts  Chris Oliver  ?
Chris Oliver
Hey guys, you'd want to setup like Cloudfront from Amazon and set it as your asset host in Rails. I'll do a video on this because it's definitely useful.

I think you could also use Cloudflare.com and may not have to configure anything as long as you have their CDN enabled.
safeMint
thanks! can't wait for the video  Chris Oliver  
safeMint
thanks for the fast turnaround on this !  Chris Oliver  
https://gorails.com/episodes/amazon-cloudfront-cdn-for-rails-assets
Chris Oliver
Just part 1 so far! It's not actually covering ActiveStorage + CDN yet, as it turns out there's no builtin support for it in Rails yet. 😫

I'm going to build a custom solution for it and cover that in the next episode.
Brandon B.
Dang  Chris Oliver , awesome turnaround.
Chris Sonnier I didn't know you where in this group as well (Saw it when doing the mentions to find Chris Oliver, haha)! Hello fellow ROR dev!!!
Chris Oliver  wanted to make sure this didn't get lost.  I'm getting dinged by Google SEO on mobile because its saying my content is not getting delivered fast enough and to use a CDN! 
Chris Oliver
safeMint  You'll have to wait for Rails to add it to ActiveStorage or you can switch to an alternative like Shrine.
Chris Oliver
I tried implementing some stuff around it and it didn't work. There are a couple PRs on Rails working on this to keep an eye on:

https://github.com/rails/rails/pull/34581
https://github.com/rails/rails/pull/34477

Once these are done, we can probably backport them to Rails 6 if we want.
Patrick Silva
Any update on this stuff? Chris Oliver , is there any effective workaround to use CDN with ActiveStorage on Jumpstart PRO's current Rails version?
Sean Drumm
+1 this

I see this is due to be native in Rails 6.1.0: https://github.com/rails/rails/pull/34477

An option I'm considering for now is to create your own ActiveStorage service, essentially a wrapper of the existing S3 one. Blog article: https://vitobotta.com/2019/11/17/rails-active-storage-permanent-urls-digital-ocean-spaces-cloudflare/
Willard Moore
I've been looking into what to do about a CDN with Jumpstart as well as organizing files within folders on s3. Any update on either would be awesome. I think I remember hearing something about updating jumpstart to the latest version of something. If I remember right, it was going to be a big bump.
Slack conversation about this topic
Folder with active storage · Issue #32790 · rails/rails
Allow configure services for individual attachments by DmitryTsepelev · Pull Request #34935 · rails/rails

Benjamin Houy
Is there any update regarding this? I believe Rails added support for proxy CDN but there is very little info on this online so I’m wondering what the best practice is?
Notifications
You’re not receiving notifications from this thread.