Python Web Apps that Fly with CDNs Transcripts
Chapter: Integrating Static Content
Lecture: CDNs and pull zones
0:00 Before we open up the admin section over on bunny.net CDN page, let's talk real quickly about the different kinds of options
0:11 and how the CDN might interact with our data so you know which one to pick. We're going to talk about something called a pull zone.
0:20 And those are basically the origins that feed data into the large CDN network that is then shared with the rest of your users throughout the world.
0:31 And we'll see how those click together. So let's imagine we have this web user, they're over there on their browser,
0:37 could be a phone, it could even be a mobile app accessing the data over an API, doesn't matter. They just wanna make HTTP requests to your content.
0:46 And so in the HTML, we're gonna put a link that says instead of forward slash static/image, it's gonna say CDN domain/static/image.
0:57 As far as they're concerned, they're never getting data from your website. They're getting it from the CDN. So once they've gotten the HTML,
1:05 their browser says, well, let's go look for these static files. And it asks the CDN, hey CDN, I'm looking for cat.jpg. CDN says, nope, no cat.jpg here,
1:16 but that comes from a pull zone. And the pull zone is associated with this web app. and let me spring into action to first populate the network
1:25 if I can find that file. There's two ways in which this might be done. It might be done through having something like S3 or some kind of cloud storage.
1:35 So it could be a cloud drive over here and especially the CDN itself has a way to sort of connect its own cloud drive
1:44 that it will look at, which is a really great option because it's local and super fast and even replicated for the CDN itself.
1:52 So it might say, is that over here? But that's not the kind we're talking about. This is like large content, we're gonna come back to this later.
1:59 So no, not this. This is one option, it's called a storage pull zone. It's not what we're doing now for our static content.
2:07 What we're gonna do is we're gonna say CDN, you give them this public URL, kind of like ngrok actually, and you say, but come look on our website
2:16 for the matching content. So they, the website, the web browser has said, I want cat.jpg. And it tried to get it from the CDN,
2:25 the CDN knows about our location on the internet. So it comes back and says, I want /static/cat, cat.jpg. And our website says, great, I have that.
2:35 So let me go pull this out of my static files here and I'll give it back to you. When it does, the CDN starts to replicate this to different locations.
2:44 Probably not automatically, but as users ask for it from different regions, it'll replicate. We turn on what's called origin shield,
2:52 transfers will start happening within the nodes of the CDN and not ever make its way back to our web app potentially.
2:59 So it really takes the load off of distributing it. So this is called a URL or origin pull zone. Right, so we have these two kinds,
3:07 store zones or origin or URL zones. For the static content section, what we're talking about is this web server style, this URL zone.
3:18 We're gonna do that pretty much 100%. When we get to the large content section, we'll go over to the storage zone.
3:24 This might be MP3 files, this might be video, this could be user generated content like, here's a ginormous PDF I uploaded to the website
3:34 and I somehow need to share that back. Right, you wouldn't check those things into source control and then associate them with your web application.
3:42 At least my rule of thumb is the stuff that's checked in the source control and the web app itself serves, that comes out of this origin zone.
3:50 For the most part, loose files that are kept alongside your web app separately in things like S3 and other cloud storage,
3:59 that probably belongs in a storage zone or pulled directly from places like S3.