Adding a CMS to Your Flask Web App Transcripts
Chapter: Advanced markdown
Lecture: Caching integration recommended

Login or purchase this course to watch this video and the rest of the course contents.
0:00 we're not gonna go through it in this course. But just like the storage engine has extensions you can write.
0:07 We wrote one that allows us to plug in markdown sub template into our database to talk to it for content. It's really recommended.
0:15 We do the same for the cashing layer. So if you go to the X sensibility section of that library,
0:21 you can see it has this short conversation on why you care about it and then
0:26 very, very similar to what we've done or the markdown extension where we had to
0:32 write the storage engine. You can do something very similar for cashing different functions,
0:36 but basically it's the same. You do a couple of secret alchemy queries to say store this or get it from the database.
0:43 The reason you might want to care about cashing is if you ever need to expire
0:48 Those cash is like I'm gonna change the way something's rendered or I'm gonna change one of the lower level imported pieces,
0:56 but it doesn't show up until you regenerate the outer piece in the actual page. Those kinds of things, you might want to be able to do that,
1:03 but typically and Web APS. They're running in more than just one server process,
1:08 even on a single server. Something like micro whiskey might be running three or four copies so it can handle the parallelism.
1:15 And the way it works now is it's cashing the stuff in memory. So it's cashing multiple copies, which is not terrible, probably, but it's not ideal.
1:23 But what is? The problem is, if you want to reset it, there's no way to really communicate with all those different worker processes and get them all
1:29 to clear out at once, not really reliably. The other problem is, if you want your site to start really quickly and be fast, right as you turn it on,
1:37 if you have to deploy a new version of it and restart it, every single worker process is gonna have to regenerate every single page.
1:44 So in the beginning there's gonna be some slowness, and under heavy traffic, this can actually be a problem.
1:49 Have you stored in the database only gets generated once. Even when you restart, it just goes back and gets it from the database again
1:54 And if you want to clear you just delete those entries out of the database and then the next request is going to start generate,
2:01 um again. So it's really easy to clear and reset the content.

Talk Python's Mastodon Michael Kennedy's Mastodon