Take Up Code
About This Show
Take Up Code is a podcast that explains computer programming topics through fun and engaging examples that you can relate to. The guided format allows you to gain valuable understanding of topics that will reinforce your studies, allow you to train new skills that you can apply on your job, and change your thinking about what it takes to become a professional programmer. The episodes are as short as possible so you can squeeze them into your daily routine.
Most Recent Episode
201: HTML: Caching Generated Output For Speed.
3 days ago
Now that you can generate HTML, why would you ever want to go back to the old way of unchanging HTML?
It takes some amount of work to generate HTML. I’m not talking about the work to program this. Make sure to listen to the previous episode for more information. I’m talking about the work that the computer itself needs to do in order to generate HTML. You might think your computer is busy when it’s starting up an application or when uploading or downloading files, but this is called input/output or just IO for short. The computer might be busy but the processor itself will usually be just sitting around waiting for the application to be read from your hard drive or for your files to be sent over the communication lines. IO can slow down what you’re trying to do but it still leaves the processor with time to cool down.
Generating HTML has the potential to be heavily IO bound but it does need some amount of work from the processor. It shouldn’t require too much work. And the time it needs to wait around for database calls to complete so it has the basic information it needs to put the HTML files together is more than enough to let the processor cool down.
Your web site visitors certainly won’t notice a few extra microseconds as your web server figures out who the visitor is and what content should be returned as HTML.
It seems like a perfect solution. You can put the text of your website articles and pages in a database along with information about how you want your website to look such as what each menu item will do. And you can also store information about the users so your site will know which visitors should get which content.
This whole system is known as a content management system of CMS for short. That’s because you can build up your website by focusing on the content and how it should behave instead of creating all the HTML files yourself. You can let the CMS software running on your web server do all the work. You’ll probably not have to create a single HTML file yourself.
For a normal request, the CMS will generate HTML and send to the visitor. The web server forgets all about the HTML that was just sent. If another visitor lands on the same page, then the same work needs to be done all over again. Anytime you find yourself writing or using code that does anything over and over again, that’s a good opportunity to cache the results. And setting up a re