Count your chips and cache them in!

I was pleasantly surprised to find out that caching wasn’t super difficult to implement. I found this article on caching and knew that sooner or later I would have to implement it into my blog page.

What is caching?

To put it simply, caching makes websites perform faster and there are two ways (that I know of) that caching works.

Method 1. This is the caching that most people think of when they think of caching. Our internet browsers will save little snippets of web pages to be used if we return to a page. Because retrieving information from the internet is a lot slower than retrieving information from our hard drive or RAM, saving information locally will speed up sites we often visit.

Method 2. This is the method that I used for speeding up my site. The blog page of my site retrieves information from my Blogger account and then dynamically creates the HTML to be displayed. In plain English, my site was a greedy pig. If two people were to visit the same page, the server could not remember that a page had already been visited, thus it would recreate the page from scratch.

The solution. Caching, obviously. Now the second person that visits the page has the convenience of visiting a page that has already been generated and is less of a wait.

The savings. I was surprised how much time maybe 20 lines of code or so saved. It was taking some pages *gasp* almost 10 seconds to render. After the page has been cached, it’s fractions of hundreths of seconds.

Now on to the fun stuff. Look out AJAX!!!

If your page is greedy and you’re using PHP, I’d suggest taking a gander at the article.

Leave a Reply