I'm creating a website mostly for learning how mysql and php works. So far I have my web app up and running great, it's basically a Blog made by myself from scratch. It features user accounts with sessions, image uploads, mail notifications and much more. Now, I know little about performance and how things should be done (at least regarding php and mysql) so I developed this website without taking into account how php/mysql websites should be made, all I cared about was that the website worked as intended, which does so far.

However, it seems to me that I'm not doing things as it should, or maybe I am. See, every time a user browse the index page, the php script queries the mysql database to show all of the data stored for a given month (the actual month we are in). I was thinking, maybe that's a lots of the same mysql queries being made all the time if several users were to visit the site... maybe I was thinking that there should be a way to store a cached version of the site/database and it would only be refreshed when editing, adding or deleting an entry on the database. I'm guessing that's how forums and blog works, that way mysql db doesn't get too busy if the website gets too crowded.

I need someone who knows about these kind of applications to aid me, or point me in the right direction. Am I wrong by making a php script that queries the dabatase every time a user browse the site? or should I make a cached version of the page and only refresh it when new content is added and/or edited / deleted?

The latest sounds great, but I need someone to tell me how to do it or at least point me to a tutorial for reference.

Thanks