Python Web Apps that Fly with CDNs Transcripts
Chapter: Course conclusion
Lecture: Quick review and thanks

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Well, we've come to the end. Hopefully all of this exposure and practice with using a CDN has opened your eyes like
0:10 it did mine when I first experienced it to see just how easy and powerful as well as affordable a CDN can be.
0:18 How much you can improve your web application for your users, not just those who are near the server, but across the globe.
0:27 So I've had great experiences using the CDN for delivering content exactly like this that
0:32 you're listening to or consuming, as well as making the website faster. And I hope that you do as well.
0:40 So remember, we started out by looking at just the static content, everything under
0:45 slash static slash whatever, those were perfect candidates for taking the load off of our
0:51 servers and pushing them to all the 114 different locations around the world, close to our users,
0:58 but also in effect scaling up our ability to serve all that data by having many, many different servers to process that in parallel.
1:07 So if you've got something under slash static in your website, the chances are really, really
1:12 good that that belongs behind a CDN if you care about making it super, super fast globally.
1:19 Then we also realize, you know, some content is not contained within our website. It's not slash static slash user uploaded video.
1:27 No that belongs over somewhere else, right? We're storing that in a database.
1:31 We're pushing that into a cloud storage and with bony.net and other CDNs, you can create
1:37 a storage pull zone, either linking to someplace like an S3 link, or you can upload them directly to the CDN and geo replicate those as well
1:48 as we did in our large content section. All of our apps are best when they're as fast as they can be. The way we can make them incredibly fast
1:56 is just tell the browsers like, if you've ever seen this file, it's good for months and months. You don't have to come back.
2:02 You don't have to check in with us, months. Just if you see this name, you've already got it, okay?
2:08 That's great until you make a change to that, isn't it? And as soon as you make a change, all of a sudden that change is not showing up
2:17 for some of the users, but it is for others, depending on when they came to visit your site. So we talked about how to use that hashing of the file
2:25 and the cache ID to put some kind of effective version number onto every static file, as well as to flip the bit on our pull zone
2:35 to say vary by query string. So we pass something different in the query string for a static file.
2:40 That means it's a different file and come and get it again, cache that also for three months. Okay, so it's really important that you add
2:47 that cache busting functionality. Then we came to troubleshooting. With troubleshooting, we saw that the CDN itself has logs. You can go look there.
2:57 We also saw a way to add, instead of hard coding the CDN prefix for all the static content, add a variable there that we can turn on and off
3:06 so that we could actually run locally without the CDN content always needing to be fresh. And that's not useful just for troubleshooting,
3:15 but it's also really handy for development. We talked about fonts, how certain font providers might be violating the GDPR
3:24 or at least require a really aggressive statement about how you're sharing their data. Don't want that, do you?
3:30 So we use bunny.fonts.bunny.net over there, drop-in replacement for Google Fonts, very nice. And the last thing we did is we realized
3:39 that even if our Python code is running fast, that's not how users are experiencing it necessarily, right? They might get the HTML fast,
3:47 but the images and CSS really slowly. So we can do different types of performance testing with the Network tab,
3:54 as well as the Lighthouse tab of our Chrome-based browsers.


Talk Python's Mastodon Michael Kennedy's Mastodon