Olly Headey
๐ค SpeakerAppearances Over Time
Podcast Appearances
We didn't touch on the old Rails assets, the original article that you got in touch about, I suppose.
We didn't touch on the old Rails assets, the original article that you got in touch about, I suppose.
Yeah, of course. So it was one of those things where I was running an app, and I'm loathe to pay anything more than I need to, the absolute minimum amount for a server to run this thing on, right? And it's using active storage to store uploaded content, right?
Yeah, of course. So it was one of those things where I was running an app, and I'm loathe to pay anything more than I need to, the absolute minimum amount for a server to run this thing on, right? And it's using active storage to store uploaded content, right?
But the particular app that I was building involved customers uploading photos in bulk, so dragging potentially hundreds, small hundreds of photographs into a drop zone thing.
But the particular app that I was building involved customers uploading photos in bulk, so dragging potentially hundreds, small hundreds of photographs into a drop zone thing.
and uploading them all and then viewing these things in the app so you can view you know three four hundred photos in a gallery um of course it's like infinite infinite scrolls on but this is quite a lot of requests on the app when your images you know are in active storage uh and you know with my tight-fisted ways i did you know that's quite a lot of traffic in my app just on one page it's a lot of requests you know that i'm having to serve they're like these these images should really
and uploading them all and then viewing these things in the app so you can view you know three four hundred photos in a gallery um of course it's like infinite infinite scrolls on but this is quite a lot of requests on the app when your images you know are in active storage uh and you know with my tight-fisted ways i did you know that's quite a lot of traffic in my app just on one page it's a lot of requests you know that i'm having to serve they're like these these images should really
be on a CDN, why are they even, you know, the request should go directly to the CDN. I don't want these requests hitting my app. And that, you know, so that's where, that was where I started thinking, well, how do I solve this? How hard can it be? And, well, it's not that hard, but it's quite convoluted. Like, so, you know, But there were two related problems, which are slightly tangential.
be on a CDN, why are they even, you know, the request should go directly to the CDN. I don't want these requests hitting my app. And that, you know, so that's where, that was where I started thinking, well, how do I solve this? How hard can it be? And, well, it's not that hard, but it's quite convoluted. Like, so, you know, But there were two related problems, which are slightly tangential.
One being Rails assets, you know, the CSS and the JavaScript and whatnot. The other being the active storage images and solving those, getting those onto CDM, two different problems that the assets approach. Well, and I was using CloudFront because I was on AWS and all the images are on in an S3 bucket. So I thought, well, CloudFront's the obvious thing here. That must be pretty straightforward.
One being Rails assets, you know, the CSS and the JavaScript and whatnot. The other being the active storage images and solving those, getting those onto CDM, two different problems that the assets approach. Well, and I was using CloudFront because I was on AWS and all the images are on in an S3 bucket. So I thought, well, CloudFront's the obvious thing here. That must be pretty straightforward.
And I presume it's similar for other CDNs. I was just using CloudFront and had these free credits anyway, so might as well. And configuring that, and this wasn't really documented in the Rails guides particularly, kind of, but not really. And so getting the assets on there was one challenge.
And I presume it's similar for other CDNs. I was just using CloudFront and had these free credits anyway, so might as well. And configuring that, and this wasn't really documented in the Rails guides particularly, kind of, but not really. And so getting the assets on there was one challenge.
which involves kind of trying to understand exactly, you know, how to configure CloudFront and the bucket and cause and this kind of stuff. And then the other was how to do the active storage assets, particularly as well. And this is in a different use case, but similar with action text. Some were just active storage assets, you know, has one attached.
which involves kind of trying to understand exactly, you know, how to configure CloudFront and the bucket and cause and this kind of stuff. And then the other was how to do the active storage assets, particularly as well. And this is in a different use case, but similar with action text. Some were just active storage assets, you know, has one attached.
So just a file attached to a multiple files attached to a model. The other being an action text, you know, images that are inside an action text block. So indirectly, active storage on my model. And trying to solve that was kind of an interesting one as well, because you have to set up
So just a file attached to a multiple files attached to a model. The other being an action text, you know, images that are inside an action text block. So indirectly, active storage on my model. And trying to solve that was kind of an interesting one as well, because you have to set up
particular routing, direct routes to do this, and involved environment variables and understanding how to actually configure this CloudFront CDN as well, which I have to say is still part mystery. I figured out how to make it work, but why specifically certain things I had to do when recommended configurations didn't actually work?
particular routing, direct routes to do this, and involved environment variables and understanding how to actually configure this CloudFront CDN as well, which I have to say is still part mystery. I figured out how to make it work, but why specifically certain things I had to do when recommended configurations didn't actually work?