Python Web Apps that Fly with CDNs Transcripts
Lecture: Try without the CDN
0:00 Another thing you can try to see if it's a CDN problem at all or it's just something wrong with the structure of your site,
0:07 usually the static content, but it could be that some route URL is getting in the place and trying to process that instead of letting it flow through to the static files,
0:17 is to just try without the CDN. So up here, you can see we've got cdn.site.com/static/image/car.
0:27 Remember, we added that because we said, "Well, we used to just have /static/image/car, and
0:34 while that worked fine locally, that was serving everything out of one location out of our
0:39 data center for our web app and putting extra load on our web apps server as well." So we added this, but you can unravel it if you're having trouble.
0:48 You can say, "Well, just for now, let me go back and turn off the CDN by effectively just
0:54 deleting it out of the HTML, and then see how the site behaves. Does it still have the problem or no?
1:00 So this will tell you does the problem belong with the CDN or with your site directly.
1:06 Another variation here, which is what I actually use on talk Python training and the other
1:11 websites is to pass this https://cdn.site.com this CDN variable here. I pass that actually as a variable into the HTML from Python into Jinja.
1:26 And then at app startup, I can have a flag that says, what is the CDN prefix?
1:33 So if I wanted to actually use bunny.net, which I almost always do, I just leave that there.
1:38 But for example, if I'm doing lots of CSS work, and I want to, every time I hit go on the page, I don't want to have to redeploy the website.
1:49 Remember, it's on a real server on a real domain, which is where the CDN is looking not locally, like we are for this.
1:56 So I'd have to push to deploy to see those changes. So in dev mode, by default, I get the pink top version.
2:06 And then when I push to production and run the production configuration, it then uses
2:12 a different variable setting instead of just nothing that uses the CDN setting. And that way I can actually cycle between it.
2:18 If you put that in place, you could just have a flag, flip it on and off in development here. So you can try without using the CDN.
2:27 That doesn't necessarily mean going through your entire site and deleting a bunch of stuff, right?
2:32 This could be a variable that you pass over throughout your entire app, and you just change it once, and then it adapts.
2:38 But if you're not sure if the problem is with the CDN, try it without.
2:42 If it's still there, then you can just rule that out and go back to standard web stuff
2:46 and figure out like, well, why is this not showing up in my web app? Forget the CDN and then flip it back.