Home Blogging Blogging Tips Why caching is important for your blog

Why caching is important for your blog

Why cache is important to blog
“The Spike of Death”

When I saw an article about “caching” in a WordPress blog, I quickly turned my face away. I’ve had bad experiences with caching ever since I became a rich internet application developer. It creates headaches and out of date data when it’s not used correctly.

Until last week, I got an email from my hosting company, Lunarpages, telling me that my account was moved to a temporary server because it was hogging the shared server. I was shocked! It turned out that my post about Battlefield Heroes, had invited about 15,000 visitors in a 2 day span (stumbled first by ksc7)!

In a panic state, I finally researched on caching and found out about WP-SuperCache Plug-in for WordPress.

WP-SuperCache

This blog usually gets around 300-400 visitors a day. So a sudden spike of around 7000 visitors a day is totally unexpected.

Let’s try to analyze what usually happens when a reader comes to visit your blog (this is not an accurate one but simple to understand) :

  • Someone comes to a page on your blog (from search engines, blog community, links from other sites, or directly, it doesn’t matter)
  • The WordPress System will execute a bunch of PHP codes to display your content. This process includes getting your article that you have written out from the database, grabbing the theme files that you use, retrieving any comments of the post, execute all installed & activated plug-ins, and other bits and pieces.
  • The actual page will then be generated and displayed on-the-fly, dynamically.

That’s roughly how it goes. This method saves a lot of space and remove a lot of dependencies, as the WordPress system only needs to store your post contents on the database. Any changes on your theme will not affect the posts. It’s brilliant. This whole process happens in some split seconds, so you/your readers won’t notice a thing.

 

However, can you imagine having thousands of people executing these processes at the same time? This was what happened. All of a sudden, you have these thousands of PHP codes need to be served and executed to these readers at the same time. It will take some resources out from the server where your blog is hosted at. So what should we do?

Solution: Caching (or triple the server’s resources, but to what end?)

Caching in a WordPress blog works by generating a static HTML page out of your posts. So instead of generating the page on-the-fly on every page hit, the system will serve a pre-made HTML file to the user. This saves tremendous calls to the database and PHP scripts execution. The page does not need to be “created” on every single page hit anymore.

WP-SuperCache plug-in will take care all of these for you. How it works basically:

  • Someone comes to a page on your blog
  • The plug-in will check whether the post has been cached before. If not, it will generate the page dynamically as usual and present it to the user.
  • HOWEVER, this generated page will then be saved to the server as a single HTML file.
  • Another person comes to the same page.
  • The plug-in checks that the post has been cached before, and therefore presents the cache (a static HTML file), saving lots of resources and time!

You can check whether you are being served a cache or not by viewing the source of the page. For example, you can view the source of this post, and at the bottom of the page, if you see one of these lines:

<!– Cached page served by WP-Cache –> or <!– super cache –>

that means you are being served the cache of the post :)  If you have commented on my posts before, chances are that you will never see cached pages (Why? Read the documentation on the plug-in page :))

To prevent an out-of-date information (which I hate the most about caching), the plug-in will refresh the cache whenever someone posts comments or whenever a cache time out has been reached (configurable). Again, have a read on the plug-in documentation to find out more on this.

The most annoying part is probably when you are making changes on your theme files, you have to delete the cache to see the change. So make sure you have at least reached to a state where you’re happy with your current layout before installing this plug-in.


Conclusion

I’m positive that every blog needs to have a caching mechanism installed. If you haven’t got it yet, you really have to think it over. My hosting is very nice to me as they were patient in working out with me as to why this happened and waited for me to fix it up. My friends said that most of the hosting account have probably suspended your account until the issue is rectified.

So, the question is, when you’ve got a sudden boost of traffic from StumbleUpon or Digg, how ready is your blog?

But again, even if you have installed caching, there are limits that you can reach before you have to move to a dedicated hosting server with more horsepower and bandwith!

 

Related Posts at Craving Tech

How to reduce inode usage (files and folders) with a web hosting limit If you are hosting your blog or website on a shared server (or I guess, any server), you may be hitting your inodes limit at some point. In a nuts...
How to enable SSH on VaultPress (at HostGator or other web hosting) How to enable SSH on VaultPress - If you are blogging on WordPress, there is a higher chance of you backing up your WordPress blog through VaultPr...
Custom Web Design vs Templates Note: This is a guest post written by Blake Davies After a while, your company’s website becomes obsolete and needs not only improvement but a ...
Why WordPress is a Perfect Solution for Your Business’ Blog Note: This is a guest post written by Blake Davies Originally launched in 2003 as a blogging platform, WordPress is probably the most widely-us...
How to speed up your WordPress blog by excluding certain JavaScript and CSS files If you own a WordPress blog, you should know by now that the more plugins you've got, the slower your blog/website gets. This is because each inst...